Module: CommandKit::OS

Defined in:
lib/command_kit/os.rb

Overview

Provides methods for determining the current OS.

Examples

include CommandKit::OS

def main(*argv)
  if linux?
    # ...
  elsif macos?
    # ...
  elsif windows?
    # ...
  end
end

Instance Method Summary collapse

Instance Method Details

#linux?Boolean

Determines if the current OS is Linux.

Returns:

  • (Boolean)


27
28
29
# File 'lib/command_kit/os.rb', line 27

def linux?
  RUBY_PLATFORM.include?('linux')
end

#macos?Boolean

Determines if the current OS is macOS.

Returns:

  • (Boolean)


38
39
40
# File 'lib/command_kit/os.rb', line 38

def macos?
  RUBY_PLATFORM.include?('darwin')
end

#windows?Boolean

Determines if the current OS is Windows.

Returns:

  • (Boolean)


49
50
51
# File 'lib/command_kit/os.rb', line 49

def windows?
  Gem.win_platform?
end