class Sys::Platform

The Platform class provides singleton methods to tell you what OS you’re on.

Constants

ARCH

The CPU architecture

IMPL

Returns the OS type, :macosx, :linux, :mingw32, etc

OS

Returns a basic OS family, either :windows or :unix

VERSION

The version of the sys-uname gem.

Public Class Methods

bsd?() click to toggle source

Returns whether or not you’re on any BSD platform

# File lib/sys/platform.rb, line 47
def self.bsd?
  Uname.sysname =~ /bsd/i ? true : false
end
linux?() click to toggle source

Returns whether or not you’re on Linux

# File lib/sys/platform.rb, line 42
def self.linux?
  Uname.sysname =~ /linux/i ? true : false
end
mac?() click to toggle source

Returns whether or not you’re on a mac, i.e. OSX

# File lib/sys/platform.rb, line 37
def self.mac?
  Uname.sysname =~ /darwin|mac/i ? true : false
end
unix?() click to toggle source

Returns whether or not you’re on a Unixy (non-Windows) OS

# File lib/sys/platform.rb, line 32
def self.unix?
  Uname.sysname =~ /microsoft/i ? false : true
end
windows?() click to toggle source

Returns whether or not you’re on a Windows OS

# File lib/sys/platform.rb, line 27
def self.windows?
  Uname.sysname =~ /microsoft/i ? true : false
end