class OS

Quick-and-dirty substitute for OS gem.

Public Class Methods

bsd?() click to toggle source

Running on BSD Unix?

# File hack_os.rb, line 42
def self.bsd?
    host_os =~ /bsd/
end
host_os() click to toggle source

Return the value of 'host_os' in the Ruby configuration.

# File hack_os.rb, line 7
def self.host_os
    RbConfig::CONFIG['host_os']
end
linux?() click to toggle source

Running on Linux?

# File hack_os.rb, line 37
def self.linux?
    host_os =~ /linux/
end
mac?() click to toggle source

Running on Mac Os?

# File hack_os.rb, line 32
def self.mac?
    host_os =~ /darwin/
end
os_category() click to toggle source

Categorize the host OS as Windows, Mac, Linux, BSD, or unknown.

# File hack_os.rb, line 12
def self.os_category
    if OS.windows? then
        "Windows"
    elsif OS.mac?
        "Mac OS"
    elsif OS.linux?
        "Linux"
    elsif OS.bsd?
        "BSD Unix"
    else
        "UNKNOWN"
    end
end
posix?() click to toggle source

Running on a POSIX system?

# File hack_os.rb, line 47
def self.posix?
    OS::mac? or OS::linux? or OS::bsd?
end
windows?() click to toggle source

Running on Windows?

# File hack_os.rb, line 27
def self.windows?
    host_os =~ /mswin|mingw|cygwin|win32|dos|bccwin|wince|emx/
end