From: "Buddy Lindsey, Jr." Date: 2011-02-09T09:21:02+09:00 Subject: Re: Am I misunderstanding something with my YAML code? --0016e644ccd689252b049bce7042 Content-Type: text/plain; charset=ISO-8859-1 Okay, that is what I get for refactoring code. I totally missed that. I was trying to make the code a little prettier than it was and completely disregarded YAML.dump. That makes sense Thanks, Buddy --- Buddy Lindsey http://www.buddylindsey.com http://www.twitter.com/buddylindsey On Tue, Feb 8, 2011 at 6:16 PM, Ryan Davis wrote: > > On Feb 8, 2011, at 15:41 , Buddy Lindsey, Jr. wrote: > > > I thought I was grasping the concepts of yaml, but I am growing confused > as > > I am messing with it doing some example coding with it. Here is a gist of > my > > code. > > > > https://gist.github.com/817528 > > > > It works fine until it goes to load the main.yaml file at which point I > get > > the following error. > > > > yaml1.rb:37:in `
': undefined method `width' for > > # (NoMethodError) > > > > It seems like it should work. Am I just missing something or am I > > approaching it wrong. > > You're serializing yaml to yaml: > > > serialized = Square.new(2,3).to_yaml > > > > # save yaml to file > > File.open('main.yaml', 'w') do |out| > > YAML.dump(serialized, out) > > end > > % ri YAML.dump > = YAML.dump > > (from ruby core) > > ------------------------------------------------------------------------------ > dump( obj, io = nil ) > > > ------------------------------------------------------------------------------ > > Converts obj to YAML and writes the YAML result to io. > > File.open( 'animals.yaml', 'w' ) do |out| > YAML.dump( ['badger', 'elephant', 'tiger'], out ) > end > > If no io is provided, a string containing the dumped YAML is returned. > > YAML.dump( :locked ) > #=> "--- :locked" > > > --0016e644ccd689252b049bce7042--