class Traject::CSVWriter

A CSV-writer, for folks who like that sort of thing. Use DelimitedWriter for non-CSV lines (e.g., tab-delimited)

Public Class Methods

new(*args) click to toggle source
Calls superclass method Traject::DelimitedWriter::new
# File lib/traject/csv_writer.rb, line 11
def initialize(*args)
  super
  self.delimiter = nil # Let CSV take care of it
end

Public Instance Methods

_write(data) click to toggle source
# File lib/traject/csv_writer.rb, line 16
def _write(data)
  @output_file << data
end
escape(x) click to toggle source

Let CSV take care of the comma escaping

# File lib/traject/csv_writer.rb, line 27
def escape(x)
  x = x.to_s
  x.gsub! internal_delimiter, @eidelim
  x
end
open_output_file() click to toggle source

Turn the output file into a CSV writer

Calls superclass method Traject::LineWriter#open_output_file
# File lib/traject/csv_writer.rb, line 21
def open_output_file
  of = super
  CSV.new(of)
end