Processes fields with @converters, or @header_converters if headers is passed as true,
returning the converted field set. Any converter that changes the field
into something other than a String halts the
pipeline of conversion for that field. This is primarily an efficiency
shortcut.
# File lib/csv.rb, line 2200
def convert_fields(fields, headers = false)
# see if we are converting headers or fields
converters = headers ? @header_converters : @converters
fields.map.with_index do |field, index|
converters.each do |converter|
break if headers && field.nil?
field = if converter.arity == 1 # straight field converter
converter[field]
else # FieldInfo converter
header = @use_headers && !headers ? @headers[index] : nil
converter[field, FieldInfo.new(index, lineno, header)]
end
break unless field.is_a? String # short-circuit pipeline for speed
end
field # final state of each field, converted or original
end
end