Class: Version::NumericToken Private

Inherits:
Token
  • Object
show all
Extended by:
T::Sig
Defined in:
version.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

A token consisting of only numbers.

Constant Summary collapse

PATTERN =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

/[0-9]+/i.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Token

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

Constructor Details

#initialize(value) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:



181
182
183
# File 'version.rb', line 181

def initialize(value)
  super(value.to_i)
end

Instance Attribute Details

#valueInteger (readonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Integer)


178
179
180
# File 'version.rb', line 178

def value
  @value
end

Instance Method Details

#<=>(other) ⇒ Integer?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • other (T.untyped)

Returns:

  • (Integer, nil)


186
187
188
189
190
191
192
193
194
195
196
197
# File 'version.rb', line 186

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

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

#numeric?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


200
201
202
# File 'version.rb', line 200

def numeric?
  true
end