ruby 读取资料(cfg)

ruby 读取文件(cfg)#读取文件def ParseConfigFile(*keys)$str {}configFilePathconfig.cfgFile.open(

ruby 读取文件(cfg)
#读取文件
def ParseConfigFile(*keys)
$str = {}
configFilePath='config.cfg'
File.open(configFilePath){ |f|
  f.readlines.each do |i|
    keys.length.times() do |j|
      if i.include?(keys[j])
        get_split_key=i.split("=")
        $str[keys[j]] = get_split_key[1].chop
      end
    end
  end
}
end

#输出信息
def GetValue(keys)
ParseConfigFile(keys)
return $str[keys]
end

调用方法: @CONFIG_SSL(值)=GetValue('key(键)')