From: ara.t.howard@... Date: 2006-08-04T04:48:44+09:00 Subject: Re: Next Major Version (was Re: Different semantics of Proc and method call -- bug or feature?) On Fri, 4 Aug 2006, Rick DeNatale wrote: >> >> "1.8.5" < "1.10.0" >> => false > > Ah, but doing the comparison correctly in Ruby isn't that hard, in a > few minutes I came up with: > > irb(main):023:0> class Version > irb(main):024:1> include Comparable > irb(main):025:1> > irb(main):026:1* def initialize(string) > irb(main):027:2> @value = string.split('.').collect { | i | i.to_i } > irb(main):028:2> end > irb(main):029:1> > irb(main):030:1* def <=>(another) > irb(main):031:2> @value <=> another.to_ary > irb(main):032:2> end > irb(main):033:1> > irb(main):034:1* def to_ary > irb(main):035:2> @value > irb(main):036:2> end > irb(main):037:1> end > => nil > irb(main):038:0> Version.new("1.8.5") > => # > irb(main):039:0> Version.new("1.8.5") < Version.new("1.10.0") > => true > > I'd strongly suggest, that it's much better for Ruby if it tries to > stay in line as much as possible with how things are done in the open > source community. > > There's a lot of software outside of Ruby which depends on having > versions being a tuple of numbers. Since Ruby makes it easy to meet > things like that more than halfway, I think that it's better to do so. but this isn't correct by 'open source' standards http://codeforpeople.com/lib/ruby/library/library-0.0.0/doc/ http://sources.redhat.com/autobook/autobook/autobook_91.html in order to compare you have to consider the semantics of each positional number -a -- we can never obtain peace in the outer world until we make peace with ourselves. - h.h. the 14th dali lama