1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/csv.rb: Cleaned up some code with Ruby 1.9 idioms.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
jeg2 2007-12-26 04:56:03 +00:00
parent 0c48720b46
commit d8ad1e28e9
2 changed files with 10 additions and 10 deletions

View file

@ -1,3 +1,7 @@
Wed Dec 26 13:55:02 2007 James Edward Gray II <jeg2@ruby-lang.org>
* lib/csv.rb: Cleaned up some code with Ruby 1.9 idioms.
Wed Dec 26 13:29:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* array.c (tmpbuf): use rb_str_tmp_new().

View file

@ -187,12 +187,10 @@ class CSV
@header_row = header_row
# handle extra headers or fields
larger, smaller, transform = headers.size > fields.size ?
[headers, fields, :to_a] :
[fields, headers, :reverse]
@row = Array.new
larger.each_with_index do |e, i|
@row << [e, smaller[i]].send(transform)
@row = if headers.size > fields.size
headers.each_with_index.map { |header, i| [header, fields[i]] }
else
fields.each_with_index.map { |field, i| [headers[i], field] }
end
end
@ -1814,8 +1812,7 @@ class CSV
# see if we are converting headers or fields
converters = headers ? @header_converters : @converters
converted = Array.new
fields.each_with_index do |field, index|
fields.each_with_index.map do |field, index| # map_with_index
converters.each do |converter|
field = if converter.arity == 1 # straight field converter
converter[field]
@ -1825,9 +1822,8 @@ class CSV
end
break unless field.is_a? String # short-curcuit pipeline for speed
end
converted << field # final state of each field, converted or original
field # final state of each field, converted or original
end
converted
end
#