Class: Tap::Tasks::Dump::Csv

Inherits:
Tap::Tasks::Dump show all
Defined in:
lib/tap/tasks/dump/csv.rb

Overview

:startdoc::task dumps data as csv

Dumps arrays as CSV data. Each array passed to dump will be formatted into a single line of csv, ie multiple dumps build the csv results. Non-array objects are converted to arrays using to_ary.

% tap run -- load/yaml ["a", "b", "c"] --: dump/csv
a,b,c

Instance Method Summary collapse

Instance Method Details

#dump(data, io) ⇒ Object

Dumps the data to io as CSV. Data is converted to an array using to_ary.



24
25
26
# File 'lib/tap/tasks/dump/csv.rb', line 24

def dump(data, io)
  io << CSV.generate_line(data.to_ary, col_sep) + row_sep
end