Class: Version::StringToken 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 string.

Direct Known Subclasses

CompositeToken

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.

/[a-z]+/i.freeze

Instance Attribute Summary

Attributes inherited from Token

#value

Instance Method Summary collapse

Methods inherited from Token

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

Constructor Details

#initialize(value) ⇒ StringToken

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 StringToken.


112
113
114
115
116
# File 'Library/Homebrew/version.rb', line 112

def initialize(value)
  super

  @value = value.to_s
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.


118
119
120
121
122
123
124
125
126
127
# File 'Library/Homebrew/version.rb', line 118

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

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