Sha256: fddd414d467cff0738e18e70bd29a6cd3713a11804a2a33711b2005ef49108a3
Contents?: true
Size: 696 Bytes
Versions: 1
Compression:
Stored size: 696 Bytes
Contents
module CSVRb class StreamBuilder def initialize(enum, with_compression = true) @enum = enum @with_compression = with_compression @deflator = Zlib::Deflate.new end def y @enum end def set(value) y << compress(value) end def stream(row) y << compress( CSV.generate_line(row, force_quotes: true, encoding: 'utf-8') ) end def <<(row) stream(row) end def close y << @deflator.flush(Zlib::FINISH) if @with_compression end private def compress(value) @with_compression \ ? @deflator.deflate(value, Zlib::SYNC_FLUSH) \ : value end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csv_rb-6.0.2.2 | lib/csv_rb/stream_builder.rb |