Class: Version::StringToken

Inherits:
Token
  • Object
show all
Defined in:
brew/Library/Homebrew/version.rb

Direct Known Subclasses

CompositeToken

Constant Summary collapse

PATTERN =
/[a-z]+[0-9]*/i.freeze

Instance Attribute Summary

Attributes inherited from Token

#value

Instance Method Summary collapse

Methods inherited from Token

#inspect, #numeric?, #to_s

Constructor Details

#initialize(value) ⇒ StringToken

Returns a new instance of StringToken



62
63
64
# File 'brew/Library/Homebrew/version.rb', line 62

def initialize(value)
  @value = value.to_s
end

Instance Method Details

#<=>(other) ⇒ Object



66
67
68
69
70
71
72
73
# File 'brew/Library/Homebrew/version.rb', line 66

def <=>(other)
  case other
  when StringToken
    value <=> other.value
  when NumericToken, NullToken
    -Integer(other <=> self)
  end
end