Use yaml

Hi,

I need to store datas in a file, with add, remove, rotation (3 records max) features.
The datas are username, and the score number.

I heard about YAML. I looked here : https://ruby-doc.org/stdlib-1.9.3/libdoc/yaml/rdoc/YAML.html
But not too documented.

Does someone can explain me how it works ?
How i can implement that ?

Thank you very much.

Regards,

/Nathan

​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 <Class: File (Ruby 2.3.0);
the world is your mollusc.

Cheers

···

On 6 December 2016 at 17:12, Nathan Guilty <ruby@e-solutions.re> wrote:

Hi,

I need to store datas in a file, with add, remove, rotation (3 records
max) features.
The datas are username, and the score number.

I heard about YAML. I looked here : https://ruby-doc.org/stdlib-1\.
9.3/libdoc/yaml/rdoc/YAML.html
But not too documented.

Does someone can explain me how it works ?
How i can implement that ?

Thank you very much.

Regards,

/Nathan

--
  Matthew Kerwin
  http://matthew.kerwin.net.au/

I need to store datas in a file, with add, remove, rotation (3 records max) features.
The datas are username, and the score number.

I heard about YAML. I looked here : Module: YAML (Ruby 1.9.3)
But not too documented.

Does someone can explain me how it works ?
How i can implement that ?

YAML isn’t ruby-specific, so the information on it is somewhere else: http://yaml.org/ (That landing page displays as valid YAML, by the way, and makes for a good crib sheet.)

The Wikipedia page on YAML is also worth visiting; it’s fairly comprehensive.

None of this will actually help with the Syntax of the Ruby YAML library, if that’s what you are really needing. But with a better grounding in the syntax of YAML itself, you may find that the documentation you have found makes more sense?

Click here to view Company Information and Confidentiality Notice.<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer&gt;

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

···

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 <Class: File (Ruby 2.3.0);
the world is your mollusc.

--
GitHub: stomar (Marcus Stollsteimer) · GitHub
PGP: 0x6B3A101A