Module: Runtime
- Defined in:
- lib/runtime_info.rb
Overview
Interfaces to various Ruby virtual machine and platform specifics
Class Method Summary collapse
-
.arch ⇒ Object
Host CPU architecture.
- .cpu_architecture ⇒ Object
- .cpu_count ⇒ Object
-
.engine ⇒ Object
Ruby virtual machine in use.
-
.ncpus ⇒ Object
Number of physical CPU cores.
-
.os ⇒ Object
Host OS.
-
.path ⇒ Object
Path to the Ruby interpreter currently in use.
-
.platform ⇒ Object
A platform identifier containing CPU and OS information.
-
.version ⇒ Object
Version of the Ruby virtual machine in use.
Class Method Details
.arch ⇒ Object
Host CPU architecture
16 |
# File 'lib/runtime_info.rb', line 16 def arch; Config::CONFIG['host_cpu']; end |
.cpu_architecture ⇒ Object
17 |
# File 'lib/runtime_info.rb', line 17 def cpu_architecture; arch; end |
.cpu_count ⇒ Object
30 |
# File 'lib/runtime_info.rb', line 30 def cpu_count; ncpus; end |
.engine ⇒ Object
Ruby virtual machine in use
38 39 40 41 |
# File 'lib/runtime_info.rb', line 38 def engine return RUBY_ENGINE if defined? RUBY_ENGINE 'ruby' end |
.ncpus ⇒ Object
Number of physical CPU cores
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/runtime_info.rb', line 20 def ncpus case os when 'darwin' Integer(`hwprefs cpu_count`) when 'linux' cores = File.read("/proc/cpuinfo").scan(/core id\s+: \d+/).uniq.size cores > 0 ? cores : 1 else raise "don't know how to determine CPU count on #{os}" end end |
.os ⇒ Object
Host OS
33 34 35 |
# File 'lib/runtime_info.rb', line 33 def os Config::CONFIG['host_os'][/^[A-Za-z]+/] end |
.path ⇒ Object
Path to the Ruby interpreter currently in use
54 |
# File 'lib/runtime_info.rb', line 54 def path; Gem.ruby; end |
.platform ⇒ Object
A platform identifier containing CPU and OS information
13 |
# File 'lib/runtime_info.rb', line 13 def platform; RUBY_PLATFORM; end |
.version ⇒ Object
Version of the Ruby virtual machine in use
44 45 46 47 48 49 50 51 |
# File 'lib/runtime_info.rb', line 44 def version case engine when 'ruby' then RUBY_VERSION when 'jruby' then JRUBY_VERSION when 'rbx' then Rubinius::VERSION else raise "don't know how to obtain version for #{engine}" end end |