Class: Version::Token Abstract Private

Inherits:
Object show all
Extended by:
T::Helpers
Includes:
Comparable
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.

This class is abstract.

It cannot be directly instantiated. Subclasses must implement the abstract methods below.

A part of a Version.

Direct Known Subclasses

NumericToken, StringToken

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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:

  • value (String, Integer, nil)


55
56
57
# File 'version.rb', line 55

def initialize(value)
  @value = T.let(value, T.untyped)
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:



52
53
54
# File 'version.rb', line 52

def value
  @value
end

Class Method Details

.create(val) ⇒ Token

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:

Returns:



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'version.rb', line 26

def self.create(val)
  case val
  when /\A#{AlphaToken::PATTERN}\z/o   then AlphaToken
  when /\A#{BetaToken::PATTERN}\z/o    then BetaToken
  when /\A#{RCToken::PATTERN}\z/o      then RCToken
  when /\A#{PreToken::PATTERN}\z/o     then PreToken
  when /\A#{PatchToken::PATTERN}\z/o   then PatchToken
  when /\A#{PostToken::PATTERN}\z/o    then PostToken
  when /\A#{NumericToken::PATTERN}\z/o then NumericToken
  when /\A#{StringToken::PATTERN}\z/o  then StringToken
  else raise "Cannot find a matching token pattern"
  end.new(val)
end

.from(val) ⇒ Token?

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:

  • val (T.untyped)

Returns:



41
42
43
44
45
46
47
48
49
# File 'version.rb', line 41

def self.from(val)
  return NULL_TOKEN if val.nil? || (val.respond_to?(:null?) && val.null?)

  case val
  when Token   then val
  when String  then Token.create(val)
  when Integer then Token.create(val.to_s)
  end
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.

This method is abstract.

Parameters:

  • other (T.untyped)

Returns:

  • (Integer, nil)


60
# File 'version.rb', line 60

def <=>(other); end

#hashInteger

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)


68
69
70
# File 'version.rb', line 68

def hash
  value.hash
end

#inspectString

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:



63
64
65
# File 'version.rb', line 63

def inspect
  "#<#{self.class.name} #{value.inspect}>"
end

#null?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)


94
95
96
# File 'version.rb', line 94

def null?
  false
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)


89
90
91
# File 'version.rb', line 89

def numeric?
  false
end

#to_fFloat

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:

  • (Float)


73
74
75
# File 'version.rb', line 73

def to_f
  value.to_f
end

#to_iInteger

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)


78
79
80
# File 'version.rb', line 78

def to_i
  value.to_i
end

#to_sString Also known as: to_str

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:



83
84
85
# File 'version.rb', line 83

def to_s
  value.to_s
end