Class: Version::StringToken Private

Inherits:
Token
  • Object
show all
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 string.

Direct Known Subclasses

CompositeToken

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.

/[a-z]+/i.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Token

create, from, #hash, #inspect, #null?, #numeric?, #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:



155
156
157
# File 'version.rb', line 155

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

Instance Attribute Details

#valueString (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:



152
153
154
# File 'version.rb', line 152

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)


160
161
162
163
164
165
166
167
168
169
# File 'version.rb', line 160

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

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