| Class | CSV::Writer |
| In: |
lib/csv.rb
|
| Parent: | 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
str_or_writable must handle ’<<(string)’.
# File lib/csv.rb, line 686
686: def Writer.create(str_or_writable, fs = ',', rs = nil)
687: BasicWriter.new(str_or_writable, fs, rs)
688: end
Given block is called with the writer instance. str_or_writable must handle ’<<(string)’.
# File lib/csv.rb, line 674
674: def Writer.generate(str_or_writable, fs = ',', rs = nil, &block)
675: writer = Writer.create(str_or_writable, fs, rs)
676: if block
677: yield(writer)
678: writer.close
679: nil
680: else
681: writer
682: end
683: end
# File lib/csv.rb, line 703
703: def initialize(dev)
704: raise RuntimeError.new('Do not instanciate this class directly.')
705: end