def Ini.read_from_file(path)
inihash = {}
headline = nil
IO.foreach(path) do |line|
line = line.strip.split(/#/)[0]
unless line.length < 2 and line[0,1] == "="
if line[0,1] == "[" and line[line.length - 1, line.length] == "]"
headline = line[1, line.length - 2 ].strip
inihash[headline] = {}
else
key, value = line.split(/=/, 2)
key = key.strip unless key.nil?
value = value.strip unless value.nil?
unless headline.nil?
inihash[headline][key] = value
else
inihash[key] = value unless key.nil?
end
end
end
end
inihash
end