Class: LWAC::CSVFormatter

Inherits:
KeyValueFormatter show all
Defined in:
lib/lwac/export/format.rb

Overview


Output to a single CSV file

Instance Method Summary collapse

Methods inherited from KeyValueFormatter

#add_data, #initialize, #open_point

Methods inherited from Formatter

#<<, #add_data, #initialize, #open_point

Constructor Details

This class inherits a constructor from LWAC::KeyValueFormatter

Instance Method Details

#close_outputObject



128
129
130
131
# File 'lib/lwac/export/format.rb', line 128

def close_output()
  $log.info "Closing output CSV..."
  @csv.close
end

#close_pointObject



138
139
140
141
# File 'lib/lwac/export/format.rb', line 138

def close_point()
  super
  @csv << (@line.values)
end

#open_outputObject



122
123
124
125
126
# File 'lib/lwac/export/format.rb', line 122

def open_output()
  $log.info "Opening #{@config[:filename]} for writing..."
  $log.debug "Options for CSV: #{@config[:csv_opts]}"
  @csv = CSV.open(@config[:filename], 'w', @config[:csv_opts] || {})
end

#write_headerObject



133
134
135
136
# File 'lib/lwac/export/format.rb', line 133

def write_header
  $log.info "Writing header"
  @csv << @config[:fields].keys
end