Module: TableView::Formats::CSV

Included in:
Base
Defined in:
lib/table_view/formats/csv.rb

Instance Method Summary collapse

Instance Method Details

#as_csvObject



6
7
8
9
10
11
# File 'lib/table_view/formats/csv.rb', line 6

def as_csv
  StringIO.open do |io|
    write_csv_to_io(io)
    io.string
  end
end

#write_csv(filepath_or_io) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/table_view/formats/csv.rb', line 13

def write_csv(filepath_or_io)
  if filepath_or_io.is_a?(String)
    File.open(filepath_or_io, "wb") do |f|
      write_csv_to_io(f)
    end
  else
    write_csv_to_io(filepath_or_io)
  end
end