Module: Host::Linux::Processor
- Includes:
- Hashifier
- Defined in:
- lib/host/linux/processor.rb
Overview
Implements the gathering of processor information on a Linux system.
Instance Method Summary collapse
-
#core(id) ⇒ Object
returns an object containing the information of the core with the given
id
(as in/proc/cpuinfo
for example). -
#cores ⇒ Object
Returns the number of cores identified on the system.
-
#each_core ⇒ Object
Lets you iterate over the processor cores and get specific information.
-
#flags ⇒ Object
Returns an array of flags for the processor.
-
#get(key) ⇒ Object
Retrieves a specific data stored on
/proc/cpuinfo
for the given key. - #model_name ⇒ Object
-
#refresh ⇒ Object
Refreshes your processor information, reading from
/proc/cpuinfo
once again.
Methods included from Hashifier
Instance Method Details
#core(id) ⇒ Object
23 24 25 26 |
# File 'lib/host/linux/processor.rb', line 23 def core(id) @current_core = @info[id] self end |
#cores ⇒ Object
Returns the number of cores identified on the system
12 13 14 |
# File 'lib/host/linux/processor.rb', line 12 def cores @info.size end |
#each_core ⇒ Object
Lets you iterate over the processor cores and get specific information. Similar to iterate on cores
, using Host::Processor.core
30 31 32 33 34 35 |
# File 'lib/host/linux/processor.rb', line 30 def each_core @info.each { |processor| @current_core = processor yield self } end |
#flags ⇒ Object
Returns an array of flags for the processor
42 43 44 45 46 47 48 |
# File 'lib/host/linux/processor.rb', line 42 def flags if @current_core && @current_core.has_key?(:flags) @current_core[:flags].split else [] end end |
#get(key) ⇒ Object
Retrieves a specific data stored on /proc/cpuinfo
for the given key.
52 53 54 |
# File 'lib/host/linux/processor.rb', line 52 def get(key) @current_core && @current_core[key.to_sym] end |
#model_name ⇒ Object
37 38 39 |
# File 'lib/host/linux/processor.rb', line 37 def model_name @current_core && @current_core[:model_name] end |
#refresh ⇒ Object
Refreshes your processor information, reading from /proc/cpuinfo
once again
58 59 60 61 |
# File 'lib/host/linux/processor.rb', line 58 def refresh get_cpuinfo(true) self end |