From: "Ara.T.Howard" Date: 2005-11-02T11:12:30+09:00 Subject: Re: Planning FasterCSV (was Re: csv.rb a start on refactoring.) On Wed, 2 Nov 2005, NAKAMURA, Hiroshi wrote: > Agreed. Please find the new implementation at > http://dev.ctor.org/csv/browser/trunk/lib . CSV.parse etc. handles above > keyword-argument-like style, too. nice. > I added :row_factory argument to CSV::Table.parse. So the following should > work now. Do you think it's enough? i do. nice approach (row_factory) btw. > require 'arrayfields' > class MyRow < Array > include ArrayFields # I don't like destructive lib... 2c. me neither - note that a 'require "arrayfields"' adds only one method to Array though - an Array __object__ is exteneded with ArrayFields __only__ if the fields are set. eg require 'arrayfields' a = 0, 1, 2 a.fields = %( zero one two ) b = 0, 1, 2 here b has only a 'fields=' method in addition to regular Array methods. a has all the ArrayFields behaviour. but maybe you probably knew that... ;-) > def self.create(fieldname, row) > row = new(row) > row.fields = fieldname > row > end > end > > CSV::Table.parse(STDIN, :row_factory => MyRow) do |row| > p row.values_at("a", "b") > } > // NaHi_165 (http://jp.ctor.org/d/nahi_2005-10-25.html#self.2eto_i) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ why all the food? it looks good - but i can't read ;-) -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | anything that contradicts experience and logic should be abandoned. | -- h.h. the 14th dalai lama ===============================================================================