-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, Ara.T.Howard wrote: > i think that would adequate. two comments > > - i'm hugely in favour of keyword style interfaces like > > def parse(str_or_readable, opts = {}, &block) > fs = opts.values_at('fs', :fs).first > rs = opts.values_at('rs', :rs).first > > vs. > > def parse(str_or_readable, fs = nil, rs = nil, &block) > > because it makes it much more possible to add functionality without > breaking the interface later, eg: > > def parse(str_or_readable, opts = {}, &block) > fs = opts.values_at('fs', :fs).first > rs = opts.values_at('rs', :rs).first > strict = opts.values_at('strict', :strict).first > > and because i personally find > > parse io, true, false > > slight obtuse to read, espcially as the number of optional paramters > increases. 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. > - i do agree that the most light-weight field naming scheme, think > that one > might be too light-weight. i have found that having named fields leads > naturally to wanting to write code such as > > name, ssn, age = row.values_at 'name', 'ssn', 'age' > > row.update 'name' => 'matz', 'age' => '?' Sounds good. > and arrayfields has already done the heavy lifting here - though one > could > certainly re-write some of it for a slightly lighter weight approach - > though it's plenty light weight imho. I added :row_factory argument to CSV::Table.parse. So the following should work now. Do you think it's enough? require 'arrayfields' class MyRow < Array include ArrayFields # I don't like destructive lib... 2c. 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") } Regards, // NaHi_165 (http://jp.ctor.org/d/nahi_2005-10-25.html#self.2eto_i) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Cygwin) iD8DBQFDaBFRf6b33ts2dPkRAujzAJwLHeL5rA1HNU90Pn3l2Nzqo0B+mQCeKfhs hqlwZgbf98qLy5gZhXkZCG0= =BB5X -----END PGP SIGNATURE-----