Class: Version::Token Private
- Inherits:
-
Object
- Object
- Version::Token
- Includes:
- Comparable
- 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 part of a Version.
Direct Known Subclasses
Instance Attribute Summary collapse
- #value ⇒ Object readonly private
Class Method Summary collapse
- .create(val) ⇒ Object private
- .from(val) ⇒ Object private
Instance Method Summary collapse
- #hash ⇒ Object private
-
#initialize(value) ⇒ Token
constructor
private
A new instance of Token.
- #inspect ⇒ Object private
- #numeric? ⇒ Boolean private
- #to_f ⇒ Object private
- #to_i ⇒ Object private
- #to_s ⇒ Object (also: #to_str) private
Constructor Details
#initialize(value) ⇒ Token
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 Token.
47 48 49 |
# File 'Library/Homebrew/version.rb', line 47 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
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.
45 46 47 |
# File 'Library/Homebrew/version.rb', line 45 def value @value end |
Class Method Details
.create(val) ⇒ 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.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'Library/Homebrew/version.rb', line 20 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 end.new(val) end |
.from(val) ⇒ 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.
35 36 37 38 39 40 41 42 43 |
# File 'Library/Homebrew/version.rb', line 35 def self.from(val) case val when Token then val when String then Token.create(val) when Integer then Token.create(val.to_s) when nil then NULL_TOKEN else NULL_TOKEN if val.respond_to?(:null?) && val.null? end end |
Instance Method Details
#hash ⇒ 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.
55 56 57 |
# File 'Library/Homebrew/version.rb', line 55 def hash value.hash end |
#inspect ⇒ 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.
51 52 53 |
# File 'Library/Homebrew/version.rb', line 51 def inspect "#<#{self.class.name} #{value.inspect}>" end |
#numeric? ⇒ Boolean
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.
72 73 74 |
# File 'Library/Homebrew/version.rb', line 72 def numeric? false end |
#to_f ⇒ 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.
59 60 61 |
# File 'Library/Homebrew/version.rb', line 59 def to_f value.to_f end |
#to_i ⇒ 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.
63 64 65 |
# File 'Library/Homebrew/version.rb', line 63 def to_i value.to_i end |
#to_s ⇒ Object Also known as: to_str
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.
67 68 69 |
# File 'Library/Homebrew/version.rb', line 67 def to_s value.to_s end |