From: djberg96@... (Daniel Berger) Date: 2004-06-14T22:23:37+09:00 Subject: Re: [RCR]: Replace pack and unpack with OO versions dejaspam@batkins.com (Bill Atkins) wrote in message news:... > Rather than having code like this: > > flags, ignore, length, name = data.unpack "nnna*" > > let's try this: > > u = Unpacker.new data > flags, ignore, length, name = u.word, u.word, u.word, u.string > > I think this looks a lot neater and is much more maintainable. A > similar thing could be done with pack. > > p = Packer.new > p.word 0x01 > p.word 0x00 > p.word 0x08 > p.string "ERERER" > > p.to_s => packed version > > Any ideas on this before I draft it up into a real RCR? > > Bill Atkins I mentioned this a *long* time ago, but didn't get much feedback. If I recall, I was inspired in part by the port of Spreadsheet::WriteExcel, in which there's a lot of pack/unpack going on. http://ruby-talk.com/cgi-bin/scat.rb/ruby/ruby-talk/44847 I definitely support the idea. Regards, Dan