Class: Xport::CSV::Formatter
- Inherits:
-
Object
- Object
- Xport::CSV::Formatter
- Defined in:
- lib/xport/formatters/csv.rb
Instance Method Summary collapse
- #add_row(worksheet, row) ⇒ Object (also: #add_header_row)
- #add_worksheet ⇒ Object
- #column_widths(worksheet, *widths) ⇒ Object
-
#initialize(export) ⇒ Formatter
constructor
A new instance of Formatter.
- #merge_header_cells(worksheet, range) ⇒ Object
- #to_file ⇒ Object
Constructor Details
#initialize(export) ⇒ Formatter
Returns a new instance of Formatter.
17 18 19 20 |
# File 'lib/xport/formatters/csv.rb', line 17 def initialize(export) @io = StringIO.new @csv = ::CSV.new(@io) end |
Instance Method Details
#add_row(worksheet, row) ⇒ Object Also known as: add_header_row
31 32 33 34 |
# File 'lib/xport/formatters/csv.rb', line 31 def add_row(worksheet, row) values = row.map { |v| v.is_a?(Xport::Cell) ? v.value : v } @csv << values end |
#add_worksheet ⇒ Object
27 28 29 |
# File 'lib/xport/formatters/csv.rb', line 27 def add_worksheet yield end |
#column_widths(worksheet, *widths) ⇒ Object
38 |
# File 'lib/xport/formatters/csv.rb', line 38 def column_widths(worksheet, *widths); end |
#merge_header_cells(worksheet, range) ⇒ Object
37 |
# File 'lib/xport/formatters/csv.rb', line 37 def merge_header_cells(worksheet, range); end |
#to_file ⇒ Object
22 23 24 25 |
# File 'lib/xport/formatters/csv.rb', line 22 def to_file @io.rewind @io end |