1 # Copyright (C) 2008 Dag Odenhall <dag.odenhall@gmail.com>
2 # Licensed under the Academic Free License version 3.0
8 # cpuinfo = ProcFile.parse_file("cpuinfo")
9 # cpuinfo[1]["model name"]
10 # #=> "AMD Turion(tm) 64 X2 Mobile Technology TL-50"
14 def self.parse_file(file)
15 file = File.expand_path(file, "/proc")
19 def initialize(string_or_io)
22 content = string_or_io
24 content = string_or_io.read
28 content.each_line do |line|
29 if sep = line.index(":")
30 @list[-1][line[0..sep-1].strip] = line[sep+1..-1].strip
35 @list.pop if @list[-1].empty?
39 @list.each do |section|