Class: Version::NumericToken

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

Constant Summary collapse

PATTERN =
/[0-9]+/i

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



73
74
75
# File 'Library/Homebrew/version.rb', line 73

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

Instance Method Details

#<=>(other) ⇒ Object



77
78
79
80
81
82
83
84
85
86
# File 'Library/Homebrew/version.rb', line 77

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

#numeric?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'Library/Homebrew/version.rb', line 88

def numeric?
  true
end