Module: RubyVersion
- Extended by:
- Comparable
- Defined in:
- lib/util/ruby_version.rb
Class Method Summary collapse
-
.<=>(other) ⇒ Object
comparable.
- .description ⇒ Object
-
.is?(other = nil) ⇒ Boolean
(also: is)
chaining for dsl-like language.
-
.major ⇒ Object
(also: main)
accessors.
- .minor ⇒ Object (also: mini)
-
.newer_than(other) ⇒ Object
(also: newer_than?)
compare dates.
- .not(other) ⇒ Object (also: not?)
- .older_than(other) ⇒ Object (also: older_than?)
- .patchlevel ⇒ Object
- .platform ⇒ Object
- .release_date ⇒ Object (also: date)
- .released_today ⇒ Object (also: released_today?)
- .tiny ⇒ Object (also: teeny)
- .to_s ⇒ Object
Class Method Details
.<=>(other) ⇒ Object
comparable
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/util/ruby_version.rb', line 35 def <=>(other) value = case other when Integer RUBY_VERSION.to_i when Float RUBY_VERSION.to_f when String RUBY_VERSION when Date,Time other.class.parse(RUBY_RELEASE_DATE) else other = other.to_s RUBY_VERSION end value <=> other end |
.description ⇒ Object
135 136 137 |
# File 'lib/util/ruby_version.rb', line 135 def description RUBY_DESCRIPTION end |
.is?(other = nil) ⇒ Boolean Also known as: is
chaining for dsl-like language
54 55 56 57 58 59 60 |
# File 'lib/util/ruby_version.rb', line 54 def is?(other = nil) if other RubyVersion == other else RubyVersion end end |
.major ⇒ Object Also known as: main
accessors
106 107 108 |
# File 'lib/util/ruby_version.rb', line 106 def major RUBY_VERSION.to_i end |
.minor ⇒ Object Also known as: mini
111 112 113 |
# File 'lib/util/ruby_version.rb', line 111 def minor RUBY_VERSION.split('.')[1].to_i end |
.newer_than(other) ⇒ Object Also known as: newer_than?
compare dates
81 82 83 84 85 86 87 |
# File 'lib/util/ruby_version.rb', line 81 def newer_than(other) if other.is_a? Date or other.is_a? Time RubyVersion > other else RUBY_RELEASE_DATE > other.to_s end end |
.not(other) ⇒ Object Also known as: not?
74 75 76 |
# File 'lib/util/ruby_version.rb', line 74 def not(other) self != other end |
.older_than(other) ⇒ Object Also known as: older_than?
90 91 92 93 94 95 96 |
# File 'lib/util/ruby_version.rb', line 90 def older_than(other) if other.is_a? Date or other.is_a? Time RubyVersion < other else RUBY_RELEASE_DATE < other.to_s end end |
.patchlevel ⇒ Object
122 123 124 |
# File 'lib/util/ruby_version.rb', line 122 def patchlevel RUBY_PATCHLEVEL end |
.platform ⇒ Object
126 127 128 |
# File 'lib/util/ruby_version.rb', line 126 def platform RUBY_PLATFORM end |
.release_date ⇒ Object Also known as: date
130 131 132 |
# File 'lib/util/ruby_version.rb', line 130 def release_date Date.parse RUBY_RELEASE_DATE end |
.released_today ⇒ Object Also known as: released_today?
99 100 101 |
# File 'lib/util/ruby_version.rb', line 99 def released_today RubyVersion.date == Date.today end |
.tiny ⇒ Object Also known as: teeny
116 117 118 |
# File 'lib/util/ruby_version.rb', line 116 def tiny RUBY_VERSION.split('.')[2].to_i end |
.to_s ⇒ Object
30 31 32 |
# File 'lib/util/ruby_version.rb', line 30 def to_s RUBY_VERSION end |