Class: Xlsxtream::IO::ZipTricks

Inherits:
Object
  • Object
show all
Defined in:
lib/xlsxtream/io/zip_tricks.rb

Constant Summary collapse

BUFFER_SIZE =
64 * 1024

Instance Method Summary collapse

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

#closeObject



26
27
28
29
# File 'lib/xlsxtream/io/zip_tricks.rb', line 26

def close
  flush_file
  @streamer.close
end