Class: Sys::Platform
- Inherits:
-
Object
- Object
- Sys::Platform
- Defined in:
- lib/sys/platform.rb,
lib/sys/uname.rb
Overview
The Platform class provides singleton methods to tell you what OS you’re on.
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 /bsd|dragonfly/i :bsd end
Class Method Summary collapse
-
.bsd? ⇒ Boolean
Returns whether or not you’re on any BSD platform.
-
.linux? ⇒ Boolean
Returns whether or not you’re on Linux.
-
.mac? ⇒ Boolean
Returns whether or not you’re on a mac, i.e.
-
.unix? ⇒ Boolean
Returns whether or not you’re on a Unixy (non-Windows) OS.
-
.windows? ⇒ Boolean
Returns whether or not you’re on a Windows OS.
Class Method Details
.bsd? ⇒ Boolean
Returns whether or not you’re on any BSD platform
47 48 49 |
# File 'lib/sys/platform.rb', line 47 def self.bsd? Uname.sysname =~ /bsd/i ? true : false end |
.linux? ⇒ Boolean
Returns whether or not you’re on Linux
42 43 44 |
# File 'lib/sys/platform.rb', line 42 def self.linux? Uname.sysname =~ /linux/i ? true : false end |
.mac? ⇒ Boolean
Returns whether or not you’re on a mac, i.e. OSX
37 38 39 |
# File 'lib/sys/platform.rb', line 37 def self.mac? Uname.sysname =~ /darwin|mac/i ? true : false end |