Easiest way to determine OS?

W

Wes Gamble

What's the easiest way to figure out if you are on a Windows vs. UNIX
platform in Ruby from within a Ruby program?

Thanks,
Wes
 
B

Brad Tilley

Wes said:
What's the easiest way to figure out if you are on a Windows vs. UNIX
platform in Ruby from within a Ruby program?

Try this:

irb(main):005:0> puts RUBY_PLATFORM
powerpc-darwin8.0
 
V

Victor \Zverok\ Shepelev

From: (e-mail address removed) [mailto:[email protected]] On Behalf Of
Brad Tilley
Sent: Monday, October 30, 2006 11:25 PM
Try this:

irb(main):005:0> puts RUBY_PLATFORM
powerpc-darwin8.0

Not very useful sometimes:

irb(main):001:0> puts RUBY_PLATFORM
i386-mswin32_71
(1) (2) (3)(4)

Here's encoded: CPU architecture (1), OS (2), CPU bits (3), compiler (4 -
it's MS Visual Studio 7.1)

Pasing this on every platform may become a pain.

v.
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top