class VpsbClient::Builders::CpuinfoParser

Constants

REGEX

model name : Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz

REGEX_PROCESSOR

Attributes

mhz[R]
model[R]
num[R]

Public Class Methods

new() click to toggle source
# File lib/vpsb_client/builders/system_info_parser.rb, line 80
def initialize
  super('cat /proc/cpuinfo')
end

Public Instance Methods

parse() click to toggle source
# File lib/vpsb_client/builders/system_info_parser.rb, line 84
def parse
  matches = find_matches(REGEX)
  matches = find_matches!(REGEX_PROCESSOR) unless matches
  @model = matches[:model]
  parse_num_processors
  parse_cpu_speed
end

Private Instance Methods

parse_cpu_speed() click to toggle source
# File lib/vpsb_client/builders/system_info_parser.rb, line 102
def parse_cpu_speed
  matches = find_matches(/^cpu MHz\s*:\s*(?<mhz>\d+)/)
  if matches
    @mhz = matches[:mhz].to_i
  else
    @mhz = nil
  end
end
parse_num_processors() click to toggle source
# File lib/vpsb_client/builders/system_info_parser.rb, line 93
def parse_num_processors
  @num = 0
  lines.each do |line|
    if line =~ /^processor\s*:\s*(?<num>\d+)/
      @num += 1
    end
  end
end