to_csv(options = Hash.new)
public
Returns the table as a complete CSV String. Headers will be listed first, then all of
the field rows.
This method assumes you want the Table.headers(), unless you explicitly
pass :write_headers => false.
# File lib/csv.rb, line 840
def to_csv(options = Hash.new)
wh = options.fetch(:write_headers, true)
@table.inject(wh ? [headers.to_csv(options)] : [ ]) do |rows, row|
if row.header_row?
rows
else
rows + [row.fields.to_csv(options)]
end
end.join('')
end