Class: DS::Util::CSVWriter
- Inherits:
-
Object
- Object
- DS::Util::CSVWriter
- Defined in:
- lib/ds/util/csv_writer.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#outfile ⇒ Object
readonly
Returns the value of attribute outfile.
Instance Method Summary collapse
-
#initialize(outfile:, headers: []) ⇒ CSVWriter
constructor
A new instance of CSVWriter.
- #write(rows = nil, &block) ⇒ Object
Constructor Details
#initialize(outfile:, headers: []) ⇒ CSVWriter
Returns a new instance of CSVWriter.
9 10 11 12 |
# File 'lib/ds/util/csv_writer.rb', line 9 def initialize outfile:, headers: [] @headers = headers @outfile = outfile end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/ds/util/csv_writer.rb', line 6 def headers @headers end |
#outfile ⇒ Object (readonly)
Returns the value of attribute outfile.
7 8 9 |
# File 'lib/ds/util/csv_writer.rb', line 7 def outfile @outfile end |
Instance Method Details
#write(rows = nil, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/ds/util/csv_writer.rb', line 14 def write rows=nil, &block if block_given? _write_with_block &block elsif rows.is_a? Enumerable _write_all rows else raise "" end end |