[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: beginners YAML question
From:       Adam Shelly <adam.shelly () gmail ! com>
Date:       2005-08-31 23:08:08
Message-ID: 4911077905083116084b78b798 () mail ! gmail ! com
[Download RAW message or body]


Thanks,
That fixed the load error, but there is still a problem with the to_yaml 
routine. The additional @size parameter never gets written to the YAML 
string.

require 'Yaml'

class Box< Array
def initialize size
@size = size
end
def size
@size
end
end


box = Box.new(2)
print "ERROR: Box, #{box.size}!=2" unless box.size == 2
box2 = YAML::load(box.to_yaml)
print "ERROR: Box2, #{box2.size}!=2" unless box2.size == 2
p box.to_yaml


ERROR: Box2, !=2 
--- !ruby/array:Box [] 


Any ideas? 
-Adam

On 8/30/05, daz <dooby@d10.karoo.co.uk> wrote:
> 
> 
> Adam Shelly wrote:
> 
> > [...] It was working fine until I tried to reload it
> > from YAML. Here is some code that reproduces the problem.
> 
> Thanks - makes it much easier :-)
> 
> > - Why doesn't it work?
> 
> A bug which seems to be fixed in a later version.
> 
> > - How can I make it work?
> 
> Edit this file:
> C:\ruby\lib\ruby\1.8\yaml\rubytypes.rb
> 
> Find two occurrences (lines 80 & 239) of:
> 
> o = obj_class.new
> 
> .... and replace both with:
> 
> o = obj_class.allocate
> 
> > Thanks,
> > -Adam
> 
> No probs,
> 
> daz
> 
> 
> 
> 
>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic