figuring out what platform i'm on

A

aslak hellesoy

Can anyone tell me how I can figure out from Ruby what platform I'm
running on? My Ruby program needs to know whether it's running on
linux, cygwin, windows etc...

Aslak
 
A

Austin Ziegler

Can anyone tell me how I can figure out from Ruby what platform I'm
running on? My Ruby program needs to know whether it's running on
linux, cygwin, windows etc...

RUBY_PLATFORM

It's not perfect, but it's a good guess.

-austin
 
F

Florian Gross

aslak said:
Can anyone tell me how I can figure out from Ruby what platform I'm
running on? My Ruby program needs to know whether it's running on
linux, cygwin, windows etc...

Use RUBY_PLATFORM or rbconfig.rb
 
K

Kent Sibilev

$ irb
irb(main):001:0> RUBY_PLATFORM
=> "powerpc-darwin7.6.0"
irb(main):002:0>

Cheers,
Kent.
 
D

Daniel Berger

Austin Ziegler said:
RUBY_PLATFORM

It's not perfect, but it's a good guess.

-austin

For more detailed information, there is sys-uname. Available on the
RAA. Yes, it works on Windows, too. :)

Regards,

Dan
 
J

Jamis Buck

Daniel said:
For more detailed information, there is sys-uname. Available on the
RAA. Yes, it works on Windows, too. :)

Regards,

Dan

And there's always the quick-and-dirty approach that has been mentioned
before, to differentiate between windows and everything else:

if File::ALT_SEPARATOR
puts "I'm on windows!"
else
puts "I'm not on windows!"
end
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top