Module: HostOS
- Defined in:
- lib/host-os.rb,
lib/host-os/support.rb,
lib/host-os/version.rb
Overview
HostOS is a module that provides information about the operating system, the current Ruby interpreter (HostOS.interpreter) and configured environment (HostOS.env). It helps you write environment-specific code in a clean way.
Defined Under Namespace
Modules: Env, Interpreter, Support
Constant Summary collapse
- NAMES =
{ bccwin: 'BCCWin', cygwin: 'Cygwin', dragonfly: 'Dragonly', freebsd: 'FreeBSD', linux: 'Linux', macosx: 'MacOSX', mingw: 'MinGW', mswin: 'MSWin', netbsd: 'NetBSD', openbsd: 'OpenBSD', sunos: 'SunOS', wince: 'WinCE', windows: 'Windows' }.compare_by_identity.freeze
- VERSION =
Returns the version number of the gem.
'0.2.0'
Class Attribute Summary collapse
-
.cygwin? ⇒ true, false
readonly
Whether the host OS is Windows/Cygwin.
-
.env ⇒ Env
readonly
Environment information.
-
.id ⇒ Symbol
readonly
OS identifier.
-
.interpreter ⇒ Interpreter
readonly
Interpreter information.
-
.linux? ⇒ true, false
readonly
Whether the host OS is identified as Linux derivate.
-
.macosx? ⇒ true, false
readonly
Whether the host OS is identified as MacOS.
-
.os2? ⇒ true, false
readonly
Whether the host OS is OS/2.
-
.posix? ⇒ true, false
readonly
This attribute is
true
when Posix compatible commands likefork
are available. -
.type ⇒ :unix, ...
readonly
OS type.
-
.unix? ⇒ true, false
readonly
Whether the host OS is a Unix OS.
-
.vms? ⇒ true, false
readonly
Whether the host OS is VMS.
-
.windows? ⇒ true, false
readonly
Whether the host OS is a Windows OS.
Class Method Summary collapse
-
.is?(what) ⇒ true, false
Whether the host OS is the given identifier or type.
Class Attribute Details
.cygwin? ⇒ true, false (readonly)
Returns whether the host OS is Windows/Cygwin.
274 275 276 |
# File 'lib/host-os.rb', line 274 def cygwin? ID == :cygwin end |
.env ⇒ Env (readonly)
Returns environment information.
232 233 234 |
# File 'lib/host-os.rb', line 232 def env Env end |
.id ⇒ Symbol (readonly)
Returns OS identifier.
214 215 216 |
# File 'lib/host-os.rb', line 214 def id ID end |
.interpreter ⇒ Interpreter (readonly)
Returns interpreter information.
226 227 228 |
# File 'lib/host-os.rb', line 226 def interpreter Interpreter end |
.linux? ⇒ true, false (readonly)
Returns whether the host OS is identified as Linux derivate.
268 269 270 |
# File 'lib/host-os.rb', line 268 def linux? ID == :linux end |
.macosx? ⇒ true, false (readonly)
Returns whether the host OS is identified as MacOS.
262 263 264 |
# File 'lib/host-os.rb', line 262 def macosx? ID == :macosx end |
.os2? ⇒ true, false (readonly)
Returns whether the host OS is OS/2.
256 257 258 |
# File 'lib/host-os.rb', line 256 def os2? TYPE == :os2 end |
.posix? ⇒ true, false (readonly)
This attribute is true
when Posix compatible commands like fork
are
available.
282 283 284 |
# File 'lib/host-os.rb', line 282 def posix? Process.respond_to?(:fork) end |
.type ⇒ :unix, ... (readonly)
Returns OS type.
220 221 222 |
# File 'lib/host-os.rb', line 220 def type TYPE end |
.unix? ⇒ true, false (readonly)
Returns whether the host OS is a Unix OS.
238 239 240 |
# File 'lib/host-os.rb', line 238 def unix? TYPE == :unix end |
.vms? ⇒ true, false (readonly)
Returns whether the host OS is VMS.
250 251 252 |
# File 'lib/host-os.rb', line 250 def vms? TYPE == :vms end |
.windows? ⇒ true, false (readonly)
Returns whether the host OS is a Windows OS.
244 245 246 |
# File 'lib/host-os.rb', line 244 def windows? TYPE == :windows end |
Class Method Details
.is?(what) ⇒ true, false
Returns whether the host OS is the given identifier or type.
288 289 290 291 292 |
# File 'lib/host-os.rb', line 288 def is?(what) return true if (ID == what) || (TYPE == what) what = defined?(what.to_sym) ? what.to_sym : what.to_s.to_sym (ID == what) || (TYPE == what) end |