Class: Version::Token Abstract Private
- Inherits:
-
Object
- Object
- Version::Token
- Extended by:
- T::Helpers, T::Sig
- 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.
It cannont be directly instantiated. Subclasses must implement the abstract
methods below.
A part of a Version.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#value ⇒ String, ...
readonly
private
Class Method Summary collapse
-
.create(val) ⇒ Token
private
-
.from(val) ⇒ Token?
private
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer?
abstract
private
-
#hash ⇒ Integer
private
-
#initialize(value) ⇒ void
constructor
private
-
#inspect ⇒ String
private
-
#null? ⇒ Boolean
private
-
#numeric? ⇒ Boolean
private
-
#to_f ⇒ Float
private
-
#to_i ⇒ Integer
private
-
#to_s ⇒ String
(also: #to_str)
private
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.
61 62 63 |
# File 'version.rb', line 61 def initialize(value) @value = T.let(value, T.untyped) end |
Instance Attribute Details
#value ⇒ String, ... (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.
58 59 60 |
# File 'version.rb', line 58 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.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'version.rb', line 30 def self.create(val) raise TypeError, "Token value must be a string; got a #{val.class} (#{val})" unless val.respond_to?(:to_str) 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.
47 48 49 50 51 52 53 54 55 |
# File 'version.rb', line 47 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.
66 |
# File 'version.rb', line 66 def <=>(other); end |
#hash ⇒ 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.
74 75 76 |
# File 'version.rb', line 74 def hash value.hash end |
#inspect ⇒ String
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.
69 70 71 |
# File 'version.rb', line 69 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.
100 101 102 |
# File 'version.rb', line 100 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.
95 96 97 |
# File 'version.rb', line 95 def numeric? false end |
#to_f ⇒ Float
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.
79 80 81 |
# File 'version.rb', line 79 def to_f value.to_f end |
#to_i ⇒ 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.
84 85 86 |
# File 'version.rb', line 84 def to_i value.to_i end |
#to_s ⇒ String 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.
89 90 91 |
# File 'version.rb', line 89 def to_s value.to_s end |