Class

CSV::Writer

Inheritance
< Object

CSV formatted string/stream writer.

EXAMPLE

  Write rows to 'csvout' file.

  outfile = File.open('csvout', 'wb')
  CSV::Writer.generate(outfile) do |csv|
    csv << ['c1', nil, '', '"', "\r\n", 'c2']
    ...
  end

  outfile.close

Methods

Class

Visibility Signature
public create (str_or_writable, fs = ',', rs = nil)
public generate (str_or_writable, fs = ',', rs = nil) {|writer| ...}
public new (dev)

Instance

Visibility Signature
public << (row)
public add_row (row)
public close ()

Class Method Detail

create(str_or_writable, fs = ',', rs = nil)

str_or_writable must handle ’<<(string)’.

generate(str_or_writable, fs = ',', rs = nil) {|writer| ...}

Given block is called with the writer instance. str_or_writable must handle ’<<(string)’.

new(dev)

Instance Method Detail

<<(row)

dump CSV stream to the device. argument must be an Array of String.

add_row(row)

Alias for #<<

close()