[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

how to print Ruby's version from within the program

SpringFlowers AutumnMoon

9/20/2007 12:46:00 PM

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
--
Posted via http://www.ruby-....

3 Answers

Stefano Crocco

9/20/2007 12:50:00 PM

0

Alle giovedì 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

James Gray

9/20/2007 12:57:00 PM

0

On Sep 20, 2007, at 7:46 AM, SpringFlowers AutumnMoon wrote:

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

>> RUBY_VERSION
=> "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

Eric Hodel

9/20/2007 7:23:00 PM

0

On Sep 20, 2007, at 05:46, SpringFlowers AutumnMoon wrote:
> 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.

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars