module Monkey::Version
Public Class Methods
new(value = "")
click to toggle source
Calls superclass method
# File lib/monkey/version.rb, line 3 def self.new(value = "") super.to_version! end
Public Instance Methods
<=>(other)
click to toggle source
Calls superclass method
# File lib/monkey/version.rb, line 19 def <=>(other) return super unless other.respond_to? :to_version mine, others = fields.dup, other.to_version.fields loop do a, b = mine.unshift, others.unshift return 0 if a.nil? and b.nil? return 1 if b.nil? or (a.is_a? Integer and b.is_a? String) return -1 if a.nil? or (b.is_a? Integer and a.is_a? String) return comp unless (comp = (a <=> b)) == 0 end end
fields()
click to toggle source
# File lib/monkey/version.rb, line 31 def fields split(".").map { |f| f =~ /^\d+$/ ? f.to_i : f } end
major()
click to toggle source
# File lib/monkey/version.rb, line 15 def major; fields[0]; end
minor()
click to toggle source
# File lib/monkey/version.rb, line 16 def minor; fields[1]; end
tiny()
click to toggle source
# File lib/monkey/version.rb, line 17 def tiny; fields[2]; end
to_version()
click to toggle source
# File lib/monkey/version.rb, line 7 def to_version self.dup end
to_version!()
click to toggle source
# File lib/monkey/version.rb, line 11 def to_version! self end