Class: Xlsxtream::IO::ZipTricks
- Inherits:
-
Object
- Object
- Xlsxtream::IO::ZipTricks
- Defined in:
- lib/xlsxtream/io/zip_tricks.rb
Constant Summary collapse
- BUFFER_SIZE =
64 * 1024
Instance Method Summary collapse
- #<<(data) ⇒ Object
- #add_file(path) ⇒ Object
- #close ⇒ Object
-
#initialize(body) ⇒ ZipTricks
constructor
A new instance of ZipTricks.
Constructor Details
#initialize(body) ⇒ ZipTricks
Returns a new instance of ZipTricks.
9 10 11 12 13 |
# File 'lib/xlsxtream/io/zip_tricks.rb', line 9 def initialize(body) @streamer = ::ZipTricks::Streamer.new(body) @wf = nil @buffer = String.new end |
Instance Method Details
#<<(data) ⇒ Object
15 16 17 18 19 |
# File 'lib/xlsxtream/io/zip_tricks.rb', line 15 def <<(data) @buffer << data flush_buffer if @buffer.size >= BUFFER_SIZE self end |
#add_file(path) ⇒ Object
21 22 23 24 |
# File 'lib/xlsxtream/io/zip_tricks.rb', line 21 def add_file(path) flush_file @wf = @streamer.write_deflated_file(path) end |
#close ⇒ Object
26 27 28 29 |
# File 'lib/xlsxtream/io/zip_tricks.rb', line 26 def close flush_file @streamer.close end |