Discovering the OS

hi list -

just wondering if there is a way to find out which OS ruby is running
on?

for these type of:

if (windows)
system “start file.html”
else if (mac)
system “open file.html”
end

  David "DC" Collier

mailto:[email protected]
+81 (0)80 6521 9559
skype: callto://d3ntaku

dc wrote:

if (windows)
system “start file.html”
else if (mac)
system “open file.html”
else
puts “Oy, nevermind! You can open it yourself!”
end

hehe

Found this on Google.
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/47795

It looks like Config::CONFIG[“arch”] is what you need to be looking at.

On Sat, 23 Sep 2006, dc wrote:

end
try this

ruby -r rbconfig -r yaml -e’ y Config::CONFIG ’

-a

dc wrote:

hi list -

just wondering if there is a way to find out which OS ruby is running
on?

for these type of:

if (windows)
system “start file.html”
else if (mac)
system “open file.html”
end

  David "DC" Collier

mailto:[email protected]
+81 (0)80 6521 9559
skype: callto://d3ntaku

RUBY_PLATFORM?

RUBY_PLATFORM
The identifier of the platform running this program. This string
is in the same form as the platform identifier used by the GNU
configure utility (which is not a coincidence).

David

William C. schrieb:

dc wrote:

if (windows)
It looks like Config::CONFIG[“arch”] is what you need to be looking at.

Hm, what about Config::CONFIG[‘target_os’] or Config::CONFIG[‘host_os’]?

Kalman

David R. wrote:

RUBY_PLATFORM
The identifier of the platform running this program. This string
is in the same form as the platform identifier used by the GNU
configure utility (which is not a coincidence).

Spoilsport. Why’s Ruby always gotta make things easy? -sigh-

Truly, that’s the hardest thing for me to get used to… I’m used to
having to work to find out things like that.