Class: Sys::Platform

Inherits:
Object
  • Object
show all
Defined in:
lib/sys/uname.rb,
lib/sys/platform.rb

Constant Summary collapse

VERSION =

The version of the sys-uname gem.

Uname::VERSION
ARCH =

The CPU architecture

File::ALT_SEPARATOR ? Uname.architecture.to_sym : Uname.machine.to_sym
OS =

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

File::ALT_SEPARATOR ? :windows : :unix
IMPL =

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

case Uname.sysname
  when /darwin|mac/i
    :macosx
  when /mingw|windows/i
    require 'rbconfig'
    RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase.to_sym
  when /linux/i
    :linux
  when /sunos|solaris/i
    :solaris
  when /bsd/i
    :bsd
end

Class Method Summary collapse

Class Method Details

.bsd?Boolean

Returns whether or not you’re on any BSD platform

Returns:

  • (Boolean)


50
51
52
# File 'lib/sys/platform.rb', line 50

def self.bsd?
  Uname.sysname =~ /bsd/i ? true : false
end

.linux?Boolean

Returns whether or not you’re on Linux

Returns:

  • (Boolean)


40
41
42
# File 'lib/sys/platform.rb', line 40

def self.linux?
  Uname.sysname =~ /linux/i ? true : false
end

.mac?Boolean

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

Returns:

  • (Boolean)


35
36
37
# File 'lib/sys/platform.rb', line 35

def self.mac?
  Uname.sysname =~ /darwin|mac/i ? true : false
end

.solaris?Boolean

Returns whether or not you’re on Solaris

Returns:

  • (Boolean)


45
46
47
# File 'lib/sys/platform.rb', line 45

def self.solaris?
  Uname.sysname =~ /sunos|solaris/i ? true : false
end

.unix?Boolean

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

Returns:

  • (Boolean)


30
31
32
# File 'lib/sys/platform.rb', line 30

def self.unix?
  Uname.sysname !~ /microsoft/i ? true : false
end

.windows?Boolean

Returns whether or not you’re on a Windows OS

Returns:

  • (Boolean)


25
26
27
# File 'lib/sys/platform.rb', line 25

def self.windows?
  Uname.sysname =~ /microsoft/i ? true : false
end