Have a ruby script output what version of ruby is running it

The RUBY_VERSION constant contains the version number of the ruby interpreter and RUBY_PATCHLEVEL contains the patchlevel, so this:

puts RUBY_VERSION

outputs e.g. 2.2.3, while this:

puts RUBY_PATCHLEVEL

outputs e.g. 173. Together it can be used like this:

ruby -e 'print "ruby #{ RUBY_VERSION }p#{ RUBY_PATCHLEVEL }"'

to output e.g. ruby 2.2.3p173

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)