Class: Tabula::Writers::TSVWriter
- Defined in:
- lib/tabula/writers/tsv_writer.rb
Overview
Writes tables in TSV (Tab-Separated Values) format
Instance Method Summary collapse
-
#write(tables, io) ⇒ Object
Write tables to an IO object.
Methods inherited from Writer
Constructor Details
This class inherits a constructor from Tabula::Writers::Writer
Instance Method Details
#write(tables, io) ⇒ Object
Write tables to an IO object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tabula/writers/tsv_writer.rb', line 10 def write(tables, io) tables.each_with_index do |table, idx| # Add blank line between tables io.puts if idx.positive? table.to_a.each do |row| # Escape tabs and newlines in cell values escaped = row.map { |cell| escape_value(cell) } io.puts escaped.join("\t") end end end |