New to YAML/Ruby.

T

Tim Mcd

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'?
 
J

Joel VanderWerf

Tim said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top