Skip to content

Instantly share code, notes, and snippets.

@tkfm-yamaguchi
Created June 20, 2014 07:25
Show Gist options
  • Save tkfm-yamaguchi/1a13c185ad7503f1ef26 to your computer and use it in GitHub Desktop.
Save tkfm-yamaguchi/1a13c185ad7503f1ef26 to your computer and use it in GitHub Desktop.
math like version number comparison in ruby
$ irb
irb(main):001:0> stable = Gem::Version.new("1.6.2")
=> #<Gem::Version "1.6.2">
irb(main):002:0> pre = Gem::Version.new("2.0.0.pre")
=> #<Gem::Version "2.0.0.pre">
irb(main):003:0> pub = Gem::Version.new("2.0.0")
=> #<Gem::Version "2.0.0">
irb(main):004:0> stable < pre
=> true
irb(main):005:0> pre < pub
=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment