Module: SProc::OSInfo

Defined in:
lib/sproc/osinfo.rb

Defined Under Namespace

Modules: OS

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.host_osObject

return the current underlying operating system



31
32
33
34
35
36
37
# File 'lib/sproc/osinfo.rb', line 31

def self.host_os
  if [OS::WINDOWS, OS::MINGW, OS::CYGWIN].include?(os_context)
    OS::WINDOWS
  else
    os_context
  end
end

.os_contextObject

returns the current execution environment



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sproc/osinfo.rb', line 18

def self.os_context
  case RbConfig::CONFIG['host_os']
  when /mswin/ then OS::WINDOWS
  when /mingw/ then OS::MINGW
  when /cygwin/ then OS::CYGWIN
  when /darwin/ then OS::OSX
  when /linux/ then OS::LINUX
  when /bsd/ then OS::BSD
  else OS::UNKNOWN
  end
end

Instance Method Details

#on_bsd?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/sproc/osinfo.rb', line 47

def on_bsd?
  OSInfo.os_context == OS::BSD
end

#on_linux?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/sproc/osinfo.rb', line 43

def on_linux?
  OSInfo.os_context == OS::LINUX
end

#on_osx?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/sproc/osinfo.rb', line 51

def on_osx?
  OSInfo.os_context == OS::OSX
end

#on_windows?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/sproc/osinfo.rb', line 39

def on_windows?
  OSInfo.host_os == OS::WINDOWS
end