how to print Ruby's version from within the program

  • Thread starter SpringFlowers AutumnMoon
  • Start date
S

SpringFlowers AutumnMoon

Is there a way to print the Ruby version from within a Ruby program?

I know i can use ruby -v at the command line, but what if it is inside
of the code and i want to print it out.

this is such as when in TextMate, i want the program to show whether it
is running under Ruby 1.8.2 or 1.8.6
 
S

Stefano Crocco

Alle gioved=C3=AC 20 settembre 2007, SpringFlowers AutumnMoon ha scritto:
Is there a way to print the Ruby version from within a Ruby program?

I know i can use ruby -v at the command line, but what if it is inside
of the code and i want to print it out.

this is such as when in TextMate, i want the program to show whether it
is running under Ruby 1.8.2 or 1.8.6

puts RUBY_VERSION

Stefano
 
J

James Edward Gray II

Is there a way to print the Ruby version from within a Ruby program?
=> "1.8.6"
this is such as when in TextMate, i want the program to show
whether it
is running under Ruby 1.8.2 or 1.8.6

TextMate shows the version and location of the used Ruby interpreter
above the program output.

James Edward Gray II
 
E

Eric Hodel

Is there a way to print the Ruby version from within a Ruby program?

I know i can use ruby -v at the command line, but what if it is inside
of the code and i want to print it out.

patchlevel = " patchlevel #{RUBY_PATCHLEVEL}" if defined?
RUBY_PATCHLEVEL
version = "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}#{patchlevel}) [#
{RUBY_PLATFORM}]"

Is the string `ruby -v` prints out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,655
Latest member
eizareri

Latest Threads

Top