Module: ProcessObserver::OS

Defined in:
lib/process_observer/os.rb

Overview

Module with methods to identify current platform.

Source: stackoverflow.com/a/171011/9293044

Class Method Summary collapse

Class Method Details

.linux?Boolean

Whether Linux (Unix but not Mac) is used.

Returns:

  • (Boolean)


29
30
31
# File 'lib/process_observer/os.rb', line 29

def OS.linux?
  OS.unix? and not OS.mac?
end

.mac?Boolean

Whether Mac is used.

Returns:

  • (Boolean)


17
18
19
# File 'lib/process_observer/os.rb', line 17

def OS.mac?
 (/darwin/ =~ RUBY_PLATFORM) != nil
end

.unix?Boolean

Whether Unix (not Windows) is used.

Returns:

  • (Boolean)


23
24
25
# File 'lib/process_observer/os.rb', line 23

def OS.unix?
  !OS.windows?
end

.windows?Boolean

Whether Windows is used.

Returns:

  • (Boolean)


11
12
13
# File 'lib/process_observer/os.rb', line 11

def OS.windows?
  (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end