Sha256: 8577f7edcb0a3c3240a9da55601fe418886ffd4416dc363f32fa1254a5ebc15f
Contents?: true
Size: 700 Bytes
Versions: 4
Compression:
Stored size: 700 Bytes
Contents
module CSVRb class StreamCSVDeflator 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
4 entries across 4 versions & 1 rubygems