Class: CSVRb::StreamCSVDeflator
- Inherits:
-
Object
- Object
- CSVRb::StreamCSVDeflator
- Defined in:
- lib/csv_rb/stream_csv_deflator.rb
Instance Method Summary collapse
- #<<(row) ⇒ Object
- #close ⇒ Object
-
#initialize(enum, with_compression = true) ⇒ StreamCSVDeflator
constructor
A new instance of StreamCSVDeflator.
- #set(value) ⇒ Object
- #stream(row) ⇒ Object
- #y ⇒ Object
Constructor Details
#initialize(enum, with_compression = true) ⇒ StreamCSVDeflator
Returns a new instance of StreamCSVDeflator.
3 4 5 6 7 |
# File 'lib/csv_rb/stream_csv_deflator.rb', line 3 def initialize(enum, with_compression = true) @enum = enum @with_compression = with_compression @deflator = Zlib::Deflate.new end |
Instance Method Details
#<<(row) ⇒ Object
23 24 25 |
# File 'lib/csv_rb/stream_csv_deflator.rb', line 23 def <<(row) stream(row) end |
#close ⇒ Object
27 28 29 |
# File 'lib/csv_rb/stream_csv_deflator.rb', line 27 def close y << @deflator.flush(Zlib::FINISH) if @with_compression end |
#set(value) ⇒ Object
13 14 15 |
# File 'lib/csv_rb/stream_csv_deflator.rb', line 13 def set(value) y << compress(value) end |
#stream(row) ⇒ Object
17 18 19 20 21 |
# File 'lib/csv_rb/stream_csv_deflator.rb', line 17 def stream(row) y << compress( CSV.generate_line(row, force_quotes: true, encoding: 'utf-8') ) end |
#y ⇒ Object
9 10 11 |
# File 'lib/csv_rb/stream_csv_deflator.rb', line 9 def y @enum end |