Module: OS

Defined in:
lib/os-name.rb,
lib/os-name/version.rb

Constant Summary collapse

VERSION =
'0.0.4'

Class Method Summary collapse

Class Method Details

.bsd?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/os-name.rb', line 48

def bsd?
  name == 'BSD'
end

.linux?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/os-name.rb', line 32

def linux?
  name == 'Linux'
end

.nameObject Also known as: to_s



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/os-name.rb', line 6

def name
  case RbConfig::CONFIG['host_os']

  when /linux/
    'Linux'
  when /darwin/
    'OS X'
  when /mswin|mingw32|windows/
    'Windows'
  when /solaris/
    'Solaris'
  when /bsd/
    'BSD'
  else
    RbConfig::CONFIG['host_os']
  end
end

.osx?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/os-name.rb', line 36

def osx?
  name == 'OS X'
end

.solaris?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/os-name.rb', line 44

def solaris?
  name == 'Solaris'
end

.to_symObject Also known as: intern



26
27
28
# File 'lib/os-name.rb', line 26

def to_sym
  name.downcase.delete(' ').to_sym
end

.windows?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/os-name.rb', line 40

def windows?
  name == 'Windows'
end