Class: IOStreams::CSV::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/io_streams/csv/writer.rb

Class Method Summary collapse

Class Method Details

.open(file_name_or_io, options = {}, &block) ⇒ Object

Write to a file / stream, compressing with GZip



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/io_streams/csv/writer.rb', line 5

def self.open(file_name_or_io, options = {}, &block)
  unless IOStreams.writer_stream?(file_name_or_io)
    ::CSV.open(file_name_or_io, 'wb', options, &block)
  else
    begin
      csv = ::CSV.new(file_name_or_io, options)
      block.call(csv)
    ensure
      csv.close if csv
    end
  end
end