Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'yaml'
- class YAMLStore
- def initialize(filename)
- if File.exists?(filename)
- @hsh = YAML.load_file(filename)
- else
- @hsh = {}
- end
- @filename = filename
- end
- def [](key)
- @hsh[key]
- end
- def []=(key, value)
- @hsh[key] = value
- write
- end
- def write
- File.open(@filename, File::RDWR | File::CREAT) { |f| YAML.dump(@hsh, f) }
- end
- end
Add Comment
Please, Sign In to add comment