Module: Ferrum::Utils::Platform
- Defined in:
- lib/ferrum/utils/platform.rb
Overview
OS and Ruby engine detection helpers, used to pick the right browser path/flags and behavior for the current platform.
Class Method Summary collapse
-
.mac? ⇒ Boolean
Whether the current platform is macOS.
-
.mac_arm? ⇒ Boolean
Whether the current platform is macOS running on Apple Silicon (arm64).
-
.mri? ⇒ Boolean
Whether the current Ruby engine is MRI (as opposed to e.g. JRuby, TruffleRuby).
-
.platform_name ⇒ :mac, ...
Detects the current platform.
-
.windows? ⇒ Boolean
Whether the current platform is Windows.
Class Method Details
.mac? ⇒ Boolean
Whether the current platform is macOS.
34 35 36 |
# File 'lib/ferrum/utils/platform.rb', line 34 def mac? RbConfig::CONFIG["host_os"] =~ /darwin/ end |
.mac_arm? ⇒ Boolean
Whether the current platform is macOS running on Apple Silicon (arm64).
41 42 43 |
# File 'lib/ferrum/utils/platform.rb', line 41 def mac_arm? mac? && RbConfig::CONFIG["host_cpu"] =~ /arm/ end |
.mri? ⇒ Boolean
Whether the current Ruby engine is MRI (as opposed to e.g. JRuby, TruffleRuby).
48 49 50 |
# File 'lib/ferrum/utils/platform.rb', line 48 def mri? defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" end |
.platform_name ⇒ :mac, ...
Detects the current platform.
17 18 19 20 21 22 |
# File 'lib/ferrum/utils/platform.rb', line 17 def platform_name return :mac if mac? return :windows if windows? :linux end |
.windows? ⇒ Boolean
Whether the current platform is Windows.
27 28 29 |
# File 'lib/ferrum/utils/platform.rb', line 27 def windows? RbConfig::CONFIG["host_os"] =~ /mingw|mswin|cygwin/ end |