lib/ruby-version.rb in ruby-version-0.2.2 vs lib/ruby-version.rb in ruby-version-0.3.0
- old
+ new
@@ -107,21 +107,31 @@
__compare(value, -1, 1, 0)
end
end
##
+ # Alias for {#compare}.
+ #
+ # @param [String, Symbol, Array] value version identifier
+ # @return [Boolean] +1+ if this one is higher, +-1+ if lower and +0+ otherwise
+ #
+
+ def self.<=>(value)
+ self.compare(value)
+ end
+
+ ##
# Brokes string identifier to numeric tokens in array.
#
# @param [String, Symbol] value version identifier
# @return [Array] array of tokens
#
def self.broke(string)
string.to_s.split(".").map! { |i| i.to_i }
end
-
-
+
##
# Contents frozen tokens array of the current ruby version.
# @see VERSION
#
@@ -136,10 +146,10 @@
if not value.array?
value = self.broke(value.to_s)
end
self::TOKENS.each_index do |i|
- case self::TOKENS[i].to_i.compare(value[i].to_i)
+ case self::TOKENS[i].to_i <=> value[i].to_i
when -1
return lower
when 1
return higher
end