Am 06.12.2016 um 08:18 schrieb Matthew Kerwin:
> Like it says on the tin: you put a string into
> YAML.load
> and you get a data structure out; you put a data structure into
> YAML.dump
> and you get a string out.
> 
> If you combine that with
> File.open <https://ruby-doc.org/core-2.3.0/File.html#method-c-open>
>  the world is your mollusc.

I'd like to point out YAML:Store, if you do not care about
handling the file operations and conversion by yourself.

It provides a simple key-value store:


require "yaml/store"

filename = "yaml_store_test.yaml"
store = YAML::Store.new(filename)

# storing some data

store.transaction do
  store[:data] = [2, 3, 5, 7, 11, 13, 17, 19]
end

# reading data

data = store.transaction { store[:data] }
puts "The stored data was: #{data}"


Regards,
Marcus


-- 
GitHub: https://github.com/stomar/
PGP:    0x6B3A101A

Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>