ruby version in code code example
Example 1: how to check ruby version
// Command line:
$ ruby -v
// Within irb type "RUBY_VERSION"
# => "2.4.1"
// If using RVM:
$ rvm current
# => ruby-2.4.1
Example 2: ruby version from script
There is a RUBY_PATCHLEVEL constant as well. So you can get your version string as
p "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
--iltempo