Class: Version::StringToken

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

Direct Known Subclasses

CompositeToken

Constant Summary collapse

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

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



56
57
58
# File 'Library/Homebrew/version.rb', line 56

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

Instance Method Details

#<=>(other) ⇒ Object



60
61
62
63
64
65
66
67
# File 'Library/Homebrew/version.rb', line 60

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