Class: Version::NumericToken

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

Constant Summary collapse

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

Instance Attribute Summary

Attributes inherited from Token

#value

Instance Method Summary collapse

Methods inherited from Token

#inspect, #to_s

Constructor Details

#initialize(value) ⇒ NumericToken

Returns a new instance of NumericToken



79
80
81
# File 'brew/Library/Homebrew/version.rb', line 79

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

Instance Method Details

#<=>(other) ⇒ Object



83
84
85
86
87
88
89
90
91
92
# File 'brew/Library/Homebrew/version.rb', line 83

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

#numeric?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'brew/Library/Homebrew/version.rb', line 94

def numeric?
  true
end