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 run(*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.
84 85 86 |
# File 'lib/command_kit/os.rb', line 84 def os @os end |
Instance Method Details
#bsd? ⇒ Boolean
Determines if the current OS is BSD based.
175 176 177 |
# File 'lib/command_kit/os.rb', line 175 def bsd? freebsd? || openbsd? || netbsd? end |
#freebsd? ⇒ Boolean
Determines if the current OS is FreeBSD.
136 137 138 |
# File 'lib/command_kit/os.rb', line 136 def freebsd? @os == :freebsd end |
#initialize(os: self.class.os, **kwargs) ⇒ Object
Initializes the command.
99 100 101 102 103 |
# File 'lib/command_kit/os.rb', line 99 def initialize(os: self.class.os, **kwargs) super(**kwargs) @os = os end |
#linux? ⇒ Boolean
Determines if the current OS is Linux.
112 113 114 |
# File 'lib/command_kit/os.rb', line 112 def linux? @os == :linux end |
#macos? ⇒ Boolean
Determines if the current OS is macOS.
123 124 125 |
# File 'lib/command_kit/os.rb', line 123 def macos? @os == :macos end |
#netbsd? ⇒ Boolean
Determines if the current OS is NetBSD.
162 163 164 |
# File 'lib/command_kit/os.rb', line 162 def netbsd? @os == :netbsd end |
#openbsd? ⇒ Boolean
Determines if the current OS is OpenBSD.
149 150 151 |
# File 'lib/command_kit/os.rb', line 149 def openbsd? @os == :openbsd end |
#unix? ⇒ Boolean
Determines if the current OS is UNIX based.
188 189 190 |
# File 'lib/command_kit/os.rb', line 188 def unix? linux? || macos? || bsd? end |
#windows? ⇒ Boolean
Determines if the current OS is Windows.
199 200 201 |
# File 'lib/command_kit/os.rb', line 199 def windows? @os == :windows end |