Class: Kiba::Uncommon::Destinations::CSV

Inherits:
Object
  • Object
show all
Defined in:
lib/kiba/uncommon/destinations/csv.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output_file) ⇒ CSV

Returns a new instance of CSV.



8
9
10
11
# File 'lib/kiba/uncommon/destinations/csv.rb', line 8

def initialize(output_file)
  @output_file = output_file
  @csv = ::CSV.open(output_file, 'w')
end

Instance Attribute Details

#output_fileObject (readonly)

Returns the value of attribute output_file.



6
7
8
# File 'lib/kiba/uncommon/destinations/csv.rb', line 6

def output_file
  @output_file
end

Instance Method Details

#closeObject



21
22
23
# File 'lib/kiba/uncommon/destinations/csv.rb', line 21

def close
  @csv.close
end

#write(row) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/kiba/uncommon/destinations/csv.rb', line 13

def write(row)
  unless @headers_written
    @headers_written = true
    @csv << row.keys
  end
  @csv << row.values
end