# File lib/chef/version_class.rb, line 35 def <=>(v) [:major, :minor, :patch].each do |method| ans = (self.send(method) <=> v.send(method)) return ans if ans != 0 end 0 end
For hash
# File lib/chef/version_class.rb, line 50 def eql?(other) other.is_a?(Version) && self == other end
# File lib/chef/version_class.rb, line 43 def hash # Didn't put any thought or research into this, probably can be # done better to_s.hash end
# File lib/chef/version_class.rb, line 56 def parse(str="") @major, @minor, @patch = case str.to_s when /^(\d+)\.(\d+)\.(\d+)$/ [ $1.to_i, $2.to_i, $3.to_i ] when /^(\d+)\.(\d+)$/ [ $1.to_i, $2.to_i, 0 ] else msg = "'#{str.to_s}' does not match 'x.y.z' or 'x.y'" raise Chef::Exceptions::InvalidCookbookVersion.new( msg ) end end
Generated with the Darkfish Rdoc Generator 2.