comparable
# File lib/ruby_version.rb, line 14 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
# File lib/ruby_version.rb, line 114 def description RUBY_DESCRIPTION end
chaining for dsl-like language
# File lib/ruby_version.rb, line 33 def is?(other = nil) if other RubyVersion == other else RubyVersion end end
accessors
# File lib/ruby_version.rb, line 85 def major RUBY_VERSION.to_i end
# File lib/ruby_version.rb, line 90 def minor RUBY_VERSION.split('.')[1].to_i end
compare dates
# File lib/ruby_version.rb, line 60 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
# File lib/ruby_version.rb, line 53 def not(other) self != other end
# File lib/ruby_version.rb, line 69 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
# File lib/ruby_version.rb, line 101 def patchlevel RUBY_PATCHLEVEL end
# File lib/ruby_version.rb, line 105 def platform RUBY_PLATFORM end
# File lib/ruby_version.rb, line 109 def release_date Date.parse RUBY_RELEASE_DATE end
# File lib/ruby_version.rb, line 78 def released_today RubyVersion.date == Date.today end
# File lib/ruby_version.rb, line 118 def revision defined?(RUBY_REVISION) && RUBY_REVISION end
# File lib/ruby_version.rb, line 95 def tiny RUBY_VERSION.split('.')[2].to_i end
# File lib/ruby_version.rb, line 8 def to_s RUBY_VERSION end