From: James Edward Gray II Date: 2005-11-22T04:36:35+09:00 Subject: Re: Problem with Pickaxe and Yaml On Nov 21, 2005, at 1:21 PM, Mark Haliday wrote: > I've got the Pickaxe book (2nd edition) and was doing some of the Yaml > code on page 417. I cannot seem to get the expected results. > > Example: > > require 'yaml' > > class Special > > def initialize(valuable, volatile, precious) > @valuable = valuable > @volatile = volatile > @precious = precious > end attr_reader :valuable > def to_yaml_properties > %w{@precious @valuable} > end > > def to_s > "#@valuable #@volatile #@precious" > end > end > > obj = Special.new("Hello", "there", "world") > data = YAML.dump(obj) > obj = YAML.load(data) > > puts obj["valuable"] puts obj.valuable Hope that helps. James Edward Gray II