Module: CommandKit::OS
- Extended by:
- ModuleMethods
- Included in:
- OpenApp, PackageManager, Sudo
- Defined in:
- lib/command_kit/os.rb,
lib/command_kit/os/linux.rb
Overview
Provides methods for determining the current OS.
Examples
require 'command_kit/command'
require 'command_kit/os'
class Command < CommandKit::Command
include CommandKit::OS
def main(*argv)
if linux?
# ...
elsif macos?
# ...
elsif freebsd?
# ...
elsif windows?
# ...
end
end
end
Defined Under Namespace
Modules: ClassMethods, Linux, ModuleMethods
Instance Attribute Summary collapse
-
#os ⇒ :linux, ...
readonly
The current OS.
Instance Method Summary collapse
-
#bsd? ⇒ Boolean
Determines if the current OS is BSD based.
-
#freebsd? ⇒ Boolean
Determines if the current OS is FreeBSD.
-
#initialize(os: self.class.os, **kwargs) ⇒ Object
Initializes the command.
-
#linux? ⇒ Boolean
Determines if the current OS is Linux.
-
#macos? ⇒ Boolean
Determines if the current OS is macOS.
-
#netbsd? ⇒ Boolean
Determines if the current OS is NetBSD.
-
#openbsd? ⇒ Boolean
Determines if the current OS is OpenBSD.
-
#unix? ⇒ Boolean
Determines if the current OS is UNIX based.
-
#windows? ⇒ Boolean
Determines if the current OS is Windows.
Methods included from ModuleMethods
Instance Attribute Details
#os ⇒ :linux, ... (readonly)
The current OS.
82 83 84 |
# File 'lib/command_kit/os.rb', line 82 def os @os end |
Instance Method Details
#bsd? ⇒ Boolean
Determines if the current OS is BSD based.
173 174 175 |
# File 'lib/command_kit/os.rb', line 173 def bsd? freebsd? || openbsd? || netbsd? end |
#freebsd? ⇒ Boolean
Determines if the current OS is FreeBSD.
134 135 136 |
# File 'lib/command_kit/os.rb', line 134 def freebsd? @os == :freebsd end |
#initialize(os: self.class.os, **kwargs) ⇒ Object
Initializes the command.
97 98 99 100 101 |
# File 'lib/command_kit/os.rb', line 97 def initialize(os: self.class.os, **kwargs) super(**kwargs) @os = os end |
#linux? ⇒ Boolean
Determines if the current OS is Linux.
110 111 112 |
# File 'lib/command_kit/os.rb', line 110 def linux? @os == :linux end |
#macos? ⇒ Boolean
Determines if the current OS is macOS.
121 122 123 |
# File 'lib/command_kit/os.rb', line 121 def macos? @os == :macos end |
#netbsd? ⇒ Boolean
Determines if the current OS is NetBSD.
160 161 162 |
# File 'lib/command_kit/os.rb', line 160 def netbsd? @os == :netbsd end |
#openbsd? ⇒ Boolean
Determines if the current OS is OpenBSD.
147 148 149 |
# File 'lib/command_kit/os.rb', line 147 def openbsd? @os == :openbsd end |
#unix? ⇒ Boolean
Determines if the current OS is UNIX based.
186 187 188 |
# File 'lib/command_kit/os.rb', line 186 def unix? linux? || macos? || bsd? end |
#windows? ⇒ Boolean
Determines if the current OS is Windows.
197 198 199 |
# File 'lib/command_kit/os.rb', line 197 def windows? @os == :windows end |