Class: DS::Util::CSVWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/ds/util/csv_writer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#headersObject (readonly)

Returns the value of attribute headers.



6
7
8
# File 'lib/ds/util/csv_writer.rb', line 6

def headers
  @headers
end

#outfileObject (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