From: Tilman Sauerbeck Date: 2005-01-15T04:05:40+09:00 Subject: Re: Style question - how to represent properties David A. Black [2005-01-14 15:31]: > 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 Yeah, I think I'll go with this. It's a "loose" format but I prefer this to Robert's suggestion (I experimented with something similar to what he proposed) cause there's less typing ;) Thanks, -- Regards, Tilman