Module: HostOS
- Extended by:
- Support
- Defined in:
- lib/host-os.rb,
lib/host-os/support.rb,
lib/host-os/version.rb,
lib/host-os/interpreter.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
- VERSION =
Version number of the gem.
'0.2.3'
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
truewhen Posix compatible commands likeforkare 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.
Attributes included from Support
#dev_null, #open_command, #rss_bytes, #suggested_thread_count, #temp_dir
Class Method Summary collapse
-
.is?(what) ⇒ true, false
Whether the host OS is the given identifier or type.
Methods included from Support
Class Attribute Details
.cygwin? ⇒ true, false (readonly)
Returns whether the host OS is Windows/Cygwin.
63 64 65 |
# File 'lib/host-os.rb', line 63 def cygwin? @id == :cygwin end |
.env ⇒ Env (readonly)
Returns environment information.
21 22 23 |
# File 'lib/host-os.rb', line 21 def env Env end |
.id ⇒ Symbol (readonly)
Returns OS identifier.
|
|
# File 'lib/host-os.rb', line 90
|
.interpreter ⇒ Interpreter (readonly)
Returns interpreter information.
15 16 17 |
# File 'lib/host-os.rb', line 15 def interpreter Interpreter end |
.linux? ⇒ true, false (readonly)
Returns whether the host OS is identified as Linux derivate.
57 58 59 |
# File 'lib/host-os.rb', line 57 def linux? @id == :linux end |
.macosx? ⇒ true, false (readonly)
Returns whether the host OS is identified as MacOS.
51 52 53 |
# File 'lib/host-os.rb', line 51 def macosx? @id == :macosx end |
.os2? ⇒ true, false (readonly)
Returns whether the host OS is OS/2.
45 46 47 |
# File 'lib/host-os.rb', line 45 def os2? @type == :os2 end |
.posix? ⇒ true, false (readonly)
This attribute is true when Posix compatible commands like fork are
available.
71 72 73 |
# File 'lib/host-os.rb', line 71 def posix? Process.respond_to?(:fork) end |
.type ⇒ :unix, ... (readonly)
Returns OS type.
11 12 13 |
# File 'lib/host-os.rb', line 11 def type @type end |
.unix? ⇒ true, false (readonly)
Returns whether the host OS is a Unix OS.
27 28 29 |
# File 'lib/host-os.rb', line 27 def unix? @type == :unix end |
.vms? ⇒ true, false (readonly)
Returns whether the host OS is VMS.
39 40 41 |
# File 'lib/host-os.rb', line 39 def vms? @type == :vms end |
.windows? ⇒ true, false (readonly)
Returns whether the host OS is a Windows OS.
33 34 35 |
# File 'lib/host-os.rb', line 33 def windows? @type == :windows end |
Class Method Details
.is?(what) ⇒ true, false
Returns whether the host OS is the given identifier or type.
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/host-os.rb', line 77 def is?(what) return (@id == what) || (@type == what) if what.is_a?(Symbol) if defined?(what.to_sym) what = what.to_sym return (@id == what) || (@type == what) end if defined?(what.to_s) what = what.to_s.to_sym return (@id == what) || (@type == what) end false end |