On 24/10/06, Ilan Berci <coder68 / yahoo.com> wrote:
> Steve Quezadas wrote:
> > Is there an easy way to save the contents of an object in ruby?
> >
>
> As a further aside to saving with yaml, yet another fantastic little
> goody that  RoR provides is the method .to_yaml() ..
>
> ilan@iberci-pc:~/rails$ script/console
> Loading development environment.
> >> "sample".to_yaml
> => "--- sample\n"

You don't need RoR for that. Merely including yaml will give objects
the to_yaml method:

irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> puts({"one"=>1,"two"=>2,"three"=>3}.to_yaml)
---
three: 3
two: 2
one: 1
=> nil

Farrel