Ruby: Print Version String from Script

, , …,

Print version from the command line:

ruby -v

Print version from within a script:

# -*- coding: utf-8 -*-
# Ruby

p RUBY_VERSION                  # "2.0.0"

Printing version from script is a important technique to find out which version your script is running. Because, you might have several version installed, and in terminal, there are aliases, links, path environment variables, various shell init scripts, that effect which Ruby version will start when you type ruby in shell.

Ruby Version Release Dates

See: Ruby Version Release Dates.

blog comments powered by Disqus