Module: System::OS
- Defined in:
- lib/system/os.rb
Overview
Information about the current Operating System (OS) running on the current system.
Constant Summary collapse
- Unknown =
Unknown OS
:unknown
- Linux =
Any OS running the Linux kernel
:linux
- Windows =
Any Windows OS
:windows
- Solaris =
Any Solaris OS
:solaris
- BSD =
Any OS running the BSD kernel
:bsd
- OSX =
Any OSX OS
:osx
- Darwin =
Any OS running the Darwin kernel
:darwin
Class Method Summary collapse
-
.bsd? ⇒ TrueClass, FalseClass
Get if the name of the operating system running on the current host is ‘System::OS::BSD`.
-
.darwin? ⇒ TrueClass, FalseClass
Get if the name of the operating system running on the current host is ‘System::OS::Darwin`.
-
.linux? ⇒ TrueClass, FalseClass
Get if the name of the operating system running on the current host is ‘System::OS::Linux`.
-
.name ⇒ Symbol
Get the name of the operating system running on the current host.
-
.osx? ⇒ TrueClass, FalseClass
Get if the name of the operating system running on the current host is ‘System::OS::OSX`.
-
.solaris? ⇒ TrueClass, FalseClass
Get if the name of the operating system running on the current host is ‘System::OS::Solaris`.
-
.windows? ⇒ TrueClass, FalseClass
Get if the name of the operating system running on the current host is ‘System::OS::Windows`.
Class Method Details
.bsd? ⇒ TrueClass, FalseClass
Get if the name of the operating system running on the current host is ‘System::OS::BSD`.
|
# File 'lib/system/os.rb', line 67
|
.darwin? ⇒ TrueClass, FalseClass
Get if the name of the operating system running on the current host is ‘System::OS::Darwin`.
94 95 96 |
# File 'lib/system/os.rb', line 94 [Linux, Windows, Solaris, BSD, OSX, Darwin].each do |name| define_method("#{name}?") { self.name == name } end |
.linux? ⇒ TrueClass, FalseClass
Get if the name of the operating system running on the current host is ‘System::OS::Linux`.
|
# File 'lib/system/os.rb', line 40
|
.name ⇒ Symbol
Get the name of the operating system running on the current host.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/system/os.rb', line 106 def name return @name if defined?(@name) os_name = System::Ruby.platform os_name = RbConfig::CONFIG['host_os'] if defined?(RbConfig::CONFIG) os_name = System.getProperty('os.name').downcase if System::Ruby.jruby? @name = case os_name when /linux/ then Linux when /solaris/ then Solaris when /bsd/ then BSD when /darwin/ then defined?(RbConfig::CONFIG) && RbConfig::CONFIG['build_vendor'] == 'apple' ? OSX : Darwin when /mac.*?os.*?x/ then OSX when /win/ then Windows # TODO: "win" is in the word "darwin"... had to move down here but need better examples of Windows OS name results... else Unknown end end |
.osx? ⇒ TrueClass, FalseClass
Get if the name of the operating system running on the current host is ‘System::OS::OSX`.
|
# File 'lib/system/os.rb', line 76
|
.solaris? ⇒ TrueClass, FalseClass
Get if the name of the operating system running on the current host is ‘System::OS::Solaris`.
|
# File 'lib/system/os.rb', line 58
|
.windows? ⇒ TrueClass, FalseClass
Get if the name of the operating system running on the current host is ‘System::OS::Windows`.
|
# File 'lib/system/os.rb', line 49
|