From: "David A. Black" Date: 2005-01-13T07:15:30+09:00 Subject: Re: Style question - how to represent properties Hi -- On Thu, 13 Jan 2005, Tilman Sauerbeck wrote: > Hi, > I'm sorry, but I couldn't think of a more concise subject line. > > I'm currently writing Ruby bindings for libeet, which serializes C > structs to disk. > > Objects that should be serializable with EET implement the > "to_eet_properties" method, which currently looks like this: > > def to_eet_properties > { > "name" => [@name], > "foobar" => [@some_fixnum, :int] > } > end > > So, to_eet_properties must return some kind of enumerable object, and > each entry has at least two attributes, a tag and value. > Optionally, there's a third attribute. If it's omitted, some default value > will be used instead. > > I'd like to improve the way the user enters these properties. > The hash-of-arrays I use currently doesn't feel like the right way to do > this, is there a better way? Maybe just arrays: def to_eet_properties return ["name", @name], ["foobar", @some_fixnum, :int] end or possible a YAML representation? David -- David A. Black dblack@wobblini.net