Class: ActsAsTable::CSV::Writer
- Inherits:
-
Writer
- Object
- Writer
- ActsAsTable::CSV::Writer
- Defined in:
- lib/acts_as_table/csv/writer.rb
Overview
ActsAsTable writer object for comma-separated values (CSV) format.
Instance Method Summary collapse
-
#initialize(row_model, output = $stdout, **options) {|writer| ... } ⇒ ActsAsTable::CSV::Writer
constructor
Returns a new ActsAsTable writer object for comma-separated values (CSV) format using the given ActsAsTable row model, output stream and options.
-
#write_row(row) ⇒ ActsAsTable::Writer
Writes a row to the output stream.
Constructor Details
#initialize(row_model, output = $stdout, **options) {|writer| ... } ⇒ ActsAsTable::CSV::Writer
Note:
Delegates output stream and options to constructor for +CSV+ object.
Returns a new ActsAsTable writer object for comma-separated values (CSV) format using the given ActsAsTable row model, output stream and options.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/acts_as_table/csv/writer.rb', line 17 def initialize(row_model, output = $stdout, **, &block) # @return [Hash<Symbol, Object>] = ([:csv] || {}).merge({ headers: false, }) @csv = ::CSV.new(output, **) super(row_model, output, **, &block) end |
Instance Method Details
#write_row(row) ⇒ ActsAsTable::Writer
Writes a row to the output stream.
32 33 34 35 36 |
# File 'lib/acts_as_table/csv/writer.rb', line 32 def write_row(row) @csv << row self end |