Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get ruby version with patch number

Tags:

ruby

I want to get ruby version with patch number. But RUBY_VERSION returns only first three numbers.

So I wrote like this:

`ruby -v`.gsub(/ruby (\d\.\d\.\dp\d+) .*\n/, $1)

But it's a little tricky. Is there any better way to do this?

like image 818
ironsand Avatar asked Aug 29 '26 16:08

ironsand


1 Answers

The constant RUBY_PATCHLEVEL gives you the current patch level.

RUBY_VERSION
=> "2.0.0"
RUBY_PATCHLEVEL
=> 247
like image 188
tessi Avatar answered Sep 01 '26 07:09

tessi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!