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
19
20
21
22
23
24
# 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/
    begin
      require 'win32/registry'
      Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Microsoft\Windows NT\CurrentVersion') do |reg|
        reg['ProductName'] # => "Ex. Windows 11 Pro?"
      end
    rescue LoadError
      "Windows (version unknown)"
    end
  elsif host =~ /darwin|mac os/
    "macOS"
  elsif host =~ /linux/
    "Linux"
  else
    host
  end
end