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) ⇒ StreamCSVDeflator
constructor
A new instance of StreamCSVDeflator.
- #set(value) ⇒ Object
- #stream(row) ⇒ Object
- #y ⇒ Object
Constructor Details
#initialize(enum) ⇒ StreamCSVDeflator
Returns a new instance of StreamCSVDeflator.
3 4 5 6 |
# File 'lib/csv_rb/stream_csv_deflator.rb', line 3 def initialize(enum) @enum = enum @deflator = Zlib::Deflate.new end |
Instance Method Details
#<<(row) ⇒ Object
21 22 23 |
# File 'lib/csv_rb/stream_csv_deflator.rb', line 21 def <<(row) stream(row) end |
#close ⇒ Object
25 26 27 |
# File 'lib/csv_rb/stream_csv_deflator.rb', line 25 def close y << @deflator.flush(Zlib::FINISH) end |
#set(value) ⇒ Object
12 13 14 |
# File 'lib/csv_rb/stream_csv_deflator.rb', line 12 def set(value) y << value end |
#stream(row) ⇒ Object
16 17 18 19 |
# File 'lib/csv_rb/stream_csv_deflator.rb', line 16 def stream(row) v = CSV.generate_line(row, force_quotes: true, encoding: 'utf-8') y << @deflator.deflate(v, Zlib::SYNC_FLUSH) end |
#y ⇒ Object
8 9 10 |
# File 'lib/csv_rb/stream_csv_deflator.rb', line 8 def y @enum end |