Module: Ruby::Version
- Defined in:
- lib/ruby-version.rb
Overview
Wraps the RUBY_VERSION
constant and provides some handling such as comparing.
Constant Summary collapse
- VERSION =
Contains the Ruby version identification in frozen string. It’s content is equal to the
RUBY_VERSION
constant. RUBY_VERSION.dup.freeze
- TOKENS =
Contents frozen tokens array of the current ruby version.
self::broke(self::VERSION).freeze
Class Method Summary collapse
-
.<(value) ⇒ Boolean
Lower operator.
-
.<=(value) ⇒ Boolean
Lower or equal operator.
-
.<=>(value) ⇒ Boolean
Alias for #compare.
-
.==(value) ⇒ Boolean
Equality operator.
-
.>(value) ⇒ Boolean
Higher operator.
-
.>=(value) ⇒ Boolean
Higher or equal operator.
-
.broke(string) ⇒ Array
Brokes string identifier to numeric tokens in array.
-
.compare(value) ⇒ Boolean
Compares version strings.
Class Method Details
.<(value) ⇒ Boolean
Lower operator.
63 64 65 66 67 |
# File 'lib/ruby-version.rb', line 63 def self.<(value) __cache(:<, value) do __compare(value, true, false, false) end end |
.<=(value) ⇒ Boolean
Lower or equal operator.
50 51 52 53 54 |
# File 'lib/ruby-version.rb', line 50 def self.<=(value) __cache(:"<=", value) do __compare(value, true, false, true) end end |
.<=>(value) ⇒ Boolean
Alias for #compare.
115 116 117 |
# File 'lib/ruby-version.rb', line 115 def self.<=>(value) self.compare(value) end |
.==(value) ⇒ Boolean
Equality operator.
89 90 91 92 93 |
# File 'lib/ruby-version.rb', line 89 def self.==(value) __cache(:"==", value) do __compare(value, false, false, true) end end |
.>(value) ⇒ Boolean
Higher operator.
76 77 78 79 80 |
# File 'lib/ruby-version.rb', line 76 def self.>(value) __cache(:>, value) do __compare(value, false, true, false) end end |
.>=(value) ⇒ Boolean
Higher or equal operator.
37 38 39 40 41 |
# File 'lib/ruby-version.rb', line 37 def self.>=(value) __cache(:">=", value) do __compare(value, false, true, true) end end |
.broke(string) ⇒ Array
Brokes string identifier to numeric tokens in array.
126 127 128 |
# File 'lib/ruby-version.rb', line 126 def self.broke(string) string.to_s.split(".").map! { |i| i.to_i } end |
.compare(value) ⇒ Boolean
Compares version strings.
102 103 104 105 106 |
# File 'lib/ruby-version.rb', line 102 def self.compare(value) __cache(:compare, value) do __compare(value, -1, 1, 0) end end |