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.4.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
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.
47 |
# File 'lib/host-os.rb', line 47 def cygwin? = (@id == :cygwin) |
.env ⇒ Env (readonly)
Returns environment information.
19 |
# File 'lib/host-os.rb', line 19 def env = Env |
.id ⇒ Symbol (readonly)
Returns OS identifier.
|
|
# File 'lib/host-os.rb', line 70
|
.interpreter ⇒ Interpreter (readonly)
Returns interpreter information.
15 |
# File 'lib/host-os.rb', line 15 def interpreter = Interpreter |
.linux? ⇒ true, false (readonly)
Returns whether the host OS is identified as Linux derivate.
43 |
# File 'lib/host-os.rb', line 43 def linux? = (@id == :linux) |
.macosx? ⇒ true, false (readonly)
Returns whether the host OS is identified as MacOS.
39 |
# File 'lib/host-os.rb', line 39 def macosx? = (@id == :macosx) |
.os2? ⇒ true, false (readonly)
Returns whether the host OS is OS/2.
35 |
# File 'lib/host-os.rb', line 35 def os2? = (@type == :os2) |
.posix? ⇒ true, false (readonly)
This attribute is true when Posix compatible commands like fork are
available.
53 |
# File 'lib/host-os.rb', line 53 def posix? = Process.respond_to?(:fork) |
.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.
23 |
# File 'lib/host-os.rb', line 23 def unix? = (@type == :unix) |
.vms? ⇒ true, false (readonly)
Returns whether the host OS is VMS.
31 |
# File 'lib/host-os.rb', line 31 def vms? = (@type == :vms) |
.windows? ⇒ true, false (readonly)
Returns whether the host OS is a Windows OS.
27 |
# File 'lib/host-os.rb', line 27 def windows? = (@type == :windows) |
Class Method Details
.is?(what) ⇒ true, false
Returns whether the host OS is the given identifier or type.
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/host-os.rb', line 57 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 |