Class: Informo::Processor
- Inherits:
-
Object
- Object
- Informo::Processor
- Defined in:
- lib/informo/processor.rb
Overview
This class is used to retrieve information about the processors available to the system.
Instance Method Summary collapse
-
#count ⇒ Object
returns the total number of processors on the system.
-
#details ⇒ Object
returns the details of the processor(s) as an array with the following information.
Instance Method Details
#count ⇒ Object
returns the total number of processors on the system
8 9 10 11 12 13 14 15 |
# File 'lib/informo/processor.rb', line 8 def count total = 0 File.open("/proc/cpuinfo").each_line do |line| total += 1 if line =~ /^processor/ end return total end |
#details ⇒ Object
returns the details of the processor(s) as an array with the following information
-
vendor (amd, intel, etc)
-
model (xeon, k9, etc)
-
speed (2000 Mhz, etc)
-
cache size (512k, etc)
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/informo/processor.rb', line 24 def details count = -1 processors = Array.new File.open("/proc/cpuinfo").each_line do |line| if line =~ /(processor|vendor_id|model name|cpu MHz|cache size)\s+:\s+(.+)/ key, value = $1, $2 if key =~ /processor/ count += 1 processors[count] = Hash.new else key = key.gsub(/\s+/,"_") processors[count][key] = value end end end return processors end |