[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Detect Mac OS X Version

Filipe

1/10/2008 9:36:00 PM

After Googling for a while I couldn't find a way of detecting the Mac
OS X version ruby is running on. I tryed the RUBY_PLATFORM constant
but it only tells me I'm running Mac OS, not its version.

Is there any other way of detecting wether the script is beeing run on
10.4 or 10.5?

Thanks :)
4 Answers

Benjamin Reed

1/10/2008 9:51:00 PM

0

On Jan 10, 2008 4:40 PM, Filipe <filipedlarcanjo@gmail.com> wrote:
> After Googling for a while I couldn't find a way of detecting the Mac
> OS X version ruby is running on. I tryed the RUBY_PLATFORM constant
> but it only tells me I'm running Mac OS, not its version.
>
> Is there any other way of detecting wether the script is beeing run on
> 10.4 or 10.5?

you can always run "sw_vers -productVersion" as a system command...

--
Benjamin Reed a.k.a. Ranger Rick
Fink, KDE, and Mac OS X development
http://www.racoo...

Lyle Johnson

1/10/2008 9:54:00 PM

0


On Jan 10, 2008, at 3:40 PM, Filipe wrote:

> After Googling for a while I couldn't find a way of detecting the Mac
> OS X version ruby is running on. I tryed the RUBY_PLATFORM constant
> but it only tells me I'm running Mac OS, not its version.
>
> Is there any other way of detecting wether the script is beeing run on
> 10.4 or 10.5?

The uname command returns the Darwin OS version, where Mac OS 10.4 is
Darwin 8.x and Mac OS 10.5 is Darwin 9.x, so this should work:

os_version = `uname -r`
if os_version =~ /^8/
# Tiger
elsif os_version =~ /^9/
# Leopard
end

Hope this helps,

Lyle

Filipe

1/10/2008 9:58:00 PM

0

Thanks :D

Roger Pack

1/10/2008 11:34:00 PM

0

or look in the ENV for variables that you can parse.

Lyle Johnson wrote:
> On Jan 10, 2008, at 3:40 PM, Filipe wrote:
>
>> After Googling for a while I couldn't find a way of detecting the Mac
>> OS X version ruby is running on. I tryed the RUBY_PLATFORM constant
>> but it only tells me I'm running Mac OS, not its version.
>>
>> Is there any other way of detecting wether the script is beeing run on
>> 10.4 or 10.5?
--
Posted via http://www.ruby-....