Class: BuildpackSupport::TokenizedVersion
- Inherits:
-
Array
- Object
- Array
- BuildpackSupport::TokenizedVersion
- Includes:
- Comparable
- Defined in:
- lib/buildpack_support/tokenized_version.rb
Overview
A utility for manipulating JRE version numbers.
Constant Summary collapse
- WILDCARD =
The wildcard component.
'+'
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer
Compare this to another array.
-
#check_size(maximum_components) ⇒ Object
Check that this version has at most the given number of components.
-
#initialize(version, allow_wildcards = true) ⇒ TokenizedVersion
constructor
Create a tokenized version based on the input string.
-
#to_s ⇒ String
Convert this to a string.
Constructor Details
#initialize(version, allow_wildcards = true) ⇒ TokenizedVersion
Create a tokenized version based on the input string.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/buildpack_support/tokenized_version.rb', line 31 def initialize(version, allow_wildcards = true) @version = version @version = WILDCARD if !@version && allow_wildcards major, tail = major_or_minor_and_tail @version minor, tail = major_or_minor_and_tail tail micro, qualifier = micro_and_qualifier tail concat [major, minor, micro, qualifier] validate allow_wildcards end |
Instance Method Details
#<=>(other) ⇒ Integer
Compare this to another array
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/buildpack_support/tokenized_version.rb', line 46 def <=>(other) comparison = 0 i = 0 while comparison == 0 && i < 3 comparison = self[i].to_i <=> other[i].to_i i += 1 end comparison = qualifier_compare(non_nil_qualifier(self[3]), non_nil_qualifier(other[3])) if comparison == 0 comparison end |
#check_size(maximum_components) ⇒ Object
Check that this version has at most the given number of components.
69 70 71 |
# File 'lib/buildpack_support/tokenized_version.rb', line 69 def check_size(maximum_components) fail "Malformed version #{self}: too many version components" if self[maximum_components] end |
#to_s ⇒ String
Convert this to a string
61 62 63 |
# File 'lib/buildpack_support/tokenized_version.rb', line 61 def to_s @version end |