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
- VERSION =
Returns the version number of the gem.
'0.1.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 like `fork` 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.
279 280 281 |
# File 'lib/host-os.rb', line 279 def cygwin? ID == :cygwin end |
.env ⇒ Env (readonly)
Returns environment information.
237 238 239 |
# File 'lib/host-os.rb', line 237 def env Env end |
.id ⇒ Symbol (readonly)
Returns OS identifier.
219 220 221 |
# File 'lib/host-os.rb', line 219 def id ID end |
.interpreter ⇒ Interpreter (readonly)
Returns interpreter information.
231 232 233 |
# File 'lib/host-os.rb', line 231 def interpreter Interpreter end |
.linux? ⇒ true, false (readonly)
Returns whether the host OS is identified as Linux derivate.
273 274 275 |
# File 'lib/host-os.rb', line 273 def linux? ID == :linux end |
.macosx? ⇒ true, false (readonly)
Returns whether the host OS is identified as MacOS.
267 268 269 |
# File 'lib/host-os.rb', line 267 def macosx? ID == :macosx end |
.os2? ⇒ true, false (readonly)
Returns whether the host OS is OS/2.
261 262 263 |
# File 'lib/host-os.rb', line 261 def os2? TYPE == :os2 end |
.posix? ⇒ true, false (readonly)
This attribute is ‘true` when Posix compatible commands like `fork` are available.
287 288 289 |
# File 'lib/host-os.rb', line 287 def posix? Process.respond_to?(:fork) end |
.type ⇒ :unix, ... (readonly)
Returns OS type.
225 226 227 |
# File 'lib/host-os.rb', line 225 def type TYPE end |
.unix? ⇒ true, false (readonly)
Returns whether the host OS is a Unix OS.
243 244 245 |
# File 'lib/host-os.rb', line 243 def unix? TYPE == :unix end |
.vms? ⇒ true, false (readonly)
Returns whether the host OS is VMS.
255 256 257 |
# File 'lib/host-os.rb', line 255 def vms? TYPE == :vms end |
.windows? ⇒ true, false (readonly)
Returns whether the host OS is a Windows OS.
249 250 251 |
# File 'lib/host-os.rb', line 249 def windows? TYPE == :windows end |
Class Method Details
.is?(what) ⇒ true, false
Returns whether the host OS is the given identifier or type.
293 294 295 296 297 |
# File 'lib/host-os.rb', line 293 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 |