summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/util/buffered_zip_output_stream.rb
diff options
context:
space:
mode:
authorPaul Kmiec <[email protected]>2023-04-29 16:23:17 -0700
committerPaul Kmiec <[email protected]>2023-05-05 09:32:55 -0700
commita4a12edab461400da629a42b2847a2242c096d91 (patch)
tree7851f5c3d2ed7369241baed70b331998d1a6c0e0 /lib/axlsx/util/buffered_zip_output_stream.rb
parente5a8faaa70337ffad6ee2a99e00c0ea3b3c69ca0 (diff)
downloadcaxlsx-a4a12edab461400da629a42b2847a2242c096d91.tar.gz
caxlsx-a4a12edab461400da629a42b2847a2242c096d91.zip
Write directly to file io instead of buffering the output in memory
Diffstat (limited to 'lib/axlsx/util/buffered_zip_output_stream.rb')
-rw-r--r--lib/axlsx/util/buffered_zip_output_stream.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/axlsx/util/buffered_zip_output_stream.rb b/lib/axlsx/util/buffered_zip_output_stream.rb
index 0025e9e2..b348dc55 100644
--- a/lib/axlsx/util/buffered_zip_output_stream.rb
+++ b/lib/axlsx/util/buffered_zip_output_stream.rb
@@ -18,19 +18,19 @@ module Axlsx
# Create a temporary directory for writing files to.
#
# The directory and its contents are removed at the end of the block.
- def self.open(file_name, encrypter = nil, &block)
+ def self.open(file_name, encrypter = nil)
Zip::OutputStream.open(file_name, encrypter) do |zos|
bzos = new(zos)
- block.call(bzos)
+ yield(bzos)
ensure
bzos.flush if bzos
end
end
- def self.write_buffer(io = ::StringIO.new, encrypter = nil, &block)
+ def self.write_buffer(io = ::StringIO.new, encrypter = nil)
Zip::OutputStream.write_buffer(io, encrypter) do |zos|
bzos = new(zos)
- block.call(bzos)
+ yield(bzos)
ensure
bzos.flush if bzos
end
@@ -51,7 +51,7 @@ module Axlsx
alias << write
def flush
- return if @buffer.size == 0
+ return if @buffer.empty?
@zos << @buffer
@buffer.clear