New to YAML/Ruby

So, I have been interested in working in YAML but have found a very
little amount of ruby specific resources. I wanted to incorporate YAML
into a basic MADlib engine for the heck of it, but I’m not to keen on
reading the rdocs… can anyone give me a basic run through on how you
would go about loading a file, and checking to see if it has the basic
variables of things like ‘story’ and ‘needed-words’?

Tim M. wrote:

So, I have been interested in working in YAML but have found a very
little amount of ruby specific resources. I wanted to incorporate YAML
into a basic MADlib engine for the heck of it, but I’m not to keen on
reading the rdocs… can anyone give me a basic run through on how you
would go about loading a file, and checking to see if it has the basic
variables of things like ‘story’ and ‘needed-words’?

If you have ri (or fastri or qri installed), you’ve got a good basic
intro. Here’s the example from running ‘ri YAML’:

      require "yaml"

      test_obj = ["dogs", "cats", "badgers"]

      yaml_obj = YAML::dump( test_obj )
                          # -> ---
                               - dogs
                               - cats
                               - badgers
      ruby_obj = YAML::load( yaml_obj )
                          # => ["dogs", "cats", "badgers"]
      ruby_obj == test_obj
                          # => true

See also YAML.load and YAML.dump in the ri docs.