Module: GDK::Machine
- Defined in:
- lib/gdk/machine.rb
Overview
Provides information about the machine
Constant Summary collapse
- ARM64_VARIATIONS =
%w[arm64 aarch64].freeze
Class Method Summary collapse
-
.architecture ⇒ String
The CPU architecture of the machine.
-
.arm64? ⇒ Boolean
Is the machine running on an ARM64 processor?.
-
.linux? ⇒ Boolean
Is the machine running Linux?.
-
.macos? ⇒ Boolean
Is the machine running MacOS?.
-
.platform ⇒ String
The kernel type the machine is running on.
-
.supported? ⇒ Boolean
Is the machine running a supported OS?.
-
.wsl? ⇒ Boolean
Is the machine running on Windows Subsystem for Linux?.
-
.x86_64? ⇒ Boolean
Is the machine running on an x86_64 processor?.
Class Method Details
.architecture ⇒ String
The CPU architecture of the machine
67 68 69 |
# File 'lib/gdk/machine.rb', line 67 def self.architecture RbConfig::CONFIG['target_cpu'] end |
.arm64? ⇒ Boolean
Is the machine running on an ARM64 processor?
39 40 41 |
# File 'lib/gdk/machine.rb', line 39 def self.arm64? ARM64_VARIATIONS.any?(architecture) end |
.linux? ⇒ Boolean
Is the machine running Linux?
11 12 13 |
# File 'lib/gdk/machine.rb', line 11 def self.linux? platform == 'linux' end |
.macos? ⇒ Boolean
Is the machine running MacOS?
18 19 20 |
# File 'lib/gdk/machine.rb', line 18 def self.macos? platform == 'darwin' end |
.platform ⇒ String
The kernel type the machine is running on
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/gdk/machine.rb', line 53 def self.platform case RbConfig::CONFIG['host_os'] when /darwin/i 'darwin' when /linux/i 'linux' else 'unknown' end end |
.supported? ⇒ Boolean
Is the machine running a supported OS?
32 33 34 |
# File 'lib/gdk/machine.rb', line 32 def self.supported? platform != 'unknown' end |
.wsl? ⇒ Boolean
Is the machine running on Windows Subsystem for Linux?
25 26 27 |
# File 'lib/gdk/machine.rb', line 25 def self.wsl? platform == 'linux' && Etc.uname[:release].include?('microsoft') end |
.x86_64? ⇒ Boolean
Is the machine running on an x86_64 processor?
46 47 48 |
# File 'lib/gdk/machine.rb', line 46 def self.x86_64? architecture == 'x86_64' end |