From: Roberto Cm Date: 2010-04-20T03:24:00+09:00 Subject: ya config file parser I'm wondering how to extend the config-yaml parser at http://www.mjijackson.com/2010/02/flexible-ruby-config-objects so I can write to the file through the variable. right now it works like this: yaml_data = " --- database: mydb auth: user: myuser pass: mypass " require 'yaml' config = Config.new(YAML.load(yaml_data)) config.auth.user # "myuser" and I want to add some magic so I can do this instead: config = Config.new(yaml_filename_variable) config.a = "test" p config.a => "test" config.write() config = nil config = Config.new(yaml_filename_variable) p config-a => "test" to load the file on new(), I changed the class like this: require 'yaml' class ConfigYaml def initialize(file) if file.nil?? then yaml_conf = YAML.load_file(file) end @data = case yaml_conf.nil? when true then YAML.load_file(file) else {} end update!(data) end private ... -- Posted via http://www.ruby-forum.com/.