Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically getting FULL Ruby version?

Tags:

version

ruby

I know it's possible to get the Ruby version (e.g. "1.9.3") via the RUBY_VERSION constant. However, I want to know how to go about determining the exact version (e.g.: "1.9.3-p0"). The reason is that there is a bug that was not fixed in earlier versions of Ruby 1.9.3 that is working in later versions, and I want some code in a gem I'm working on to account for this.

like image 287
Matt Huggins Avatar asked Aug 05 '12 19:08

Matt Huggins


2 Answers

There is a RUBY_PATCHLEVEL constant as well. So you can get your version string as

"#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" 
like image 139
iltempo Avatar answered Oct 07 '22 15:10

iltempo


At least in the newest Ruby (2.3.0), there is also a RUBY_DESCRIPTION constant:

RUBY_DESCRIPTION
# => "ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]"
like image 42
nitrogen Avatar answered Oct 07 '22 16:10

nitrogen