Module: Hyraft::SystemInfo

Defined in:
lib/hyraft/system_info.rb

Class Method Summary collapse

Class Method Details

.os_nameObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/hyraft/system_info.rb', line 6

def self.os_name
  host = RbConfig::CONFIG["host_os"]

  if host =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
    windows_name
  elsif host =~ /darwin|mac os/
    "macOS"
  elsif host =~ /linux/
    "Linux"
  else
    host
  end
end

.windows_nameObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/hyraft/system_info.rb', line 20

def self.windows_name
  require "win32/registry"

  Win32::Registry::HKEY_LOCAL_MACHINE.open(
    "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
  ) do |reg|
    reg["ProductName"]
  end

rescue LoadError
  "Windows (version unknown)"
end