From: Kurt Stephens Date: 2010-02-03T12:17:44+09:00 Subject: [ruby-core:28024] Re: RCR: RUBY_VERSION_INT I have a Version class that implements Debian version strings. http://github.com/kstephens/cabar/blob/c9946cdf80d2ed79dfdb902dac085cc83c6dbb45/lib/ruby/cabar/version.rb KAS Hugh Sasse wrote: > On Wed, 3 Feb 2010, Shot (Piotr Szotkowski) wrote: > >> Roger Pack: >> >>> Currently in a .rb file, to determine if you're on >>> 1.9 versus 1.8 is not all that straight forward. >>> Ex: To tell you're on 1.9. >>> RUBY_VERSION > '1.8' >>> except that that fails >> Ummm?? >> >>>> RUBY_VERSION >> => "1.9.1" >>>> RUBY_VERSION > '1.8' >> => true >>>> RUBY_VERSION > '1.9' >> => true >>>> RUBY_VERSION > '1.9.1' >> => false >>>> RUBY_VERSION > '1.9.0.9' >> => true >>>> '1.9.0' > '1.8' >> => true >>>> '1.9' > '1.8' >> => true >> >>> Thoughts? >> I don?t like the ?one digit? policy, but this is precisely why it was >> instituted ? to have string comparisons of version numbers ?just work?. > > Having a Version class would solve this > RUBY_VERSION > '1.9.0.9' > ArgumentError: comparison of Version with String failed > RUBY_VERSION > '1.9.0.9'.to_version > RUBY_VERSION > Version.new('1.9.0.9') > giving appropriate results. > I think it would be useful for all sorts of versionable things. > It could tie in with ranges, with arrays of versions and .include?; > and the semantics could well defined. > >> ? Shot > > Hugh >