Module: Konjac::Office::OS

Defined in:
lib/konjac/office/os.rb

Overview

A module for determining what OS we’re using

Class Method Summary collapse

Class Method Details

.linux?Boolean

OS is a version of Linux

Returns:

  • (Boolean)


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

def linux?
  @linux ||= is? /linux|cygwin/
end

.mac?Boolean

OS is a version of Mac

Returns:

  • (Boolean)


12
13
14
# File 'lib/konjac/office/os.rb', line 12

def mac?
  @mac ||= is? /mac|darwin/
end

.not_a_macObject

Throws a message if the computer is using a command restricted to Macs



33
34
35
36
37
38
39
40
# File 'lib/konjac/office/os.rb', line 33

def not_a_mac
  if mac?
    return false
  else
    puts I18n.t(:mac_only)
    return true
  end
end

.posix?Boolean

OS is POSIX (well, actually, this makes the somewhat bad assumption that non-Windows OSes are POSIX)

Returns:

  • (Boolean)


28
29
30
# File 'lib/konjac/office/os.rb', line 28

def posix?
  !windows?
end

.to_sObject

Override string output



7
8
9
# File 'lib/konjac/office/os.rb', line 7

def to_s
  RbConfig::CONFIG["host_os"]
end

.windows?Boolean

OS is a version of Windows

Returns:

  • (Boolean)


22
23
24
# File 'lib/konjac/office/os.rb', line 22

def windows?
  @windows ||= is? /mswin|^win|mingw/
end