Class: Version::NumericToken Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A token consisting of only numbers.

Constant Summary collapse

PATTERN =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

/[0-9]+/i.freeze

Instance Attribute Summary

Attributes inherited from Token

#value

Instance Method Summary collapse

Methods inherited from Token

create, from, #hash, #inspect, #to_f, #to_i, #to_s

Constructor Details

#initialize(value) ⇒ NumericToken

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of NumericToken.


137
138
139
140
141
# File 'Library/Homebrew/version.rb', line 137

def initialize(value)
  super

  @value = value.to_i
end

Instance Method Details

#<=>(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


143
144
145
146
147
148
149
150
151
152
153
154
# File 'Library/Homebrew/version.rb', line 143

def <=>(other)
  return unless other = Token.from(other)

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

#numeric?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

156
157
158
# File 'Library/Homebrew/version.rb', line 156

def numeric?
  true
end