From: Christophe Broult Date: 2002-08-22T03:41:13+09:00 Subject: RE: OS version This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C24942.497CF3B0 Content-Type: text/plain; charset="ISO-8859-1" > -----Original Message----- > From: Kontra, Gergely [mailto:kgergely@mlabdial.hit.bme.hu] > Sent: Wednesday, August 21, 2002 1:28 PM > To: ruby-talk ML > Subject: RE: OS version > > > >> Is there a way to find out the OS version from ruby? > >The above applies to *nix only. I don't how to do it in Windows. > Well, the only thing I need it for is to detect windows :) Here what I use in my scripts to detect the OS require 'rbconfig' class Helpers [...] def Helpers.platformIsWindows? Helpers.platformIsMSWin32? || Helpers.platformIsMingw32? || Helpers.platformIsCygwin? end def Helpers.platformIsCygwin? Config::CONFIG["arch"] =~ %r!.*cygwin!i end def Helpers.platformIsMingw32? Config::CONFIG["arch"] =~ %r!.*mingw32!i end def Helpers.platformIsMSWin32? Config::CONFIG["arch"] =~ %r!.*mswin32!i end [...] end ------_=_NextPart_001_01C24942.497CF3B0 Content-Type: text/html; charset="ISO-8859-1" RE: OS version

> -----Original Message-----
> From: Kontra, Gergely [mailto:kgergely@mlabdial.hit.bme.hu]
> Sent: Wednesday, August 21, 2002 1:28 PM
> To: ruby-talk ML
> Subject: RE: OS version
>
>
> >> Is there a way to find out the OS version from ruby?
> >The above applies to *nix only.  I don't how to do it in Windows.
> Well, the only thing I need it for is to detect windows :)

Here what I use in my scripts to detect the OS

require 'rbconfig'

class Helpers

[...]

    def Helpers.platformIsWindows?
      Helpers.platformIsMSWin32? ||
        Helpers.platformIsMingw32? ||
        Helpers.platformIsCygwin?
    end

    def Helpers.platformIsCygwin?
      Config::CONFIG["arch"] =~ %r!.*cygwin!i
    end
    def Helpers.platformIsMingw32?
      Config::CONFIG["arch"] =~ %r!.*mingw32!i
    end
    def Helpers.platformIsMSWin32?
      Config::CONFIG["arch"] =~ %r!.*mswin32!i
    end
[...]

end

------_=_NextPart_001_01C24942.497CF3B0--