From 1752e2c96490aa798b6b396c8e7f3c282b242fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Bu=CC=88nemann?= Date: Mon, 30 Oct 2017 20:06:35 +0100 Subject: [PATCH] Fix unitialized instance var warnings --- lib/xlsxtream/io/directory.rb | 3 ++- lib/xlsxtream/io/stream.rb | 1 + lib/xlsxtream/io/zip_tricks.rb | 1 + lib/xlsxtream/workbook.rb | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/xlsxtream/io/directory.rb b/lib/xlsxtream/io/directory.rb index 7becb46..14552fd 100644 --- a/lib/xlsxtream/io/directory.rb +++ b/lib/xlsxtream/io/directory.rb @@ -5,6 +5,7 @@ module IO class Directory def initialize(path) @path = Pathname(path) + @file = nil end def <<(data) @@ -19,7 +20,7 @@ def add_file(path) end def close - @file.close if @file.respond_to? :close + @file.close if @file end end end diff --git a/lib/xlsxtream/io/stream.rb b/lib/xlsxtream/io/stream.rb index e49c3b8..1e06961 100644 --- a/lib/xlsxtream/io/stream.rb +++ b/lib/xlsxtream/io/stream.rb @@ -3,6 +3,7 @@ module IO class Stream def initialize(stream) @stream = stream + @path = nil end def <<(data) diff --git a/lib/xlsxtream/io/zip_tricks.rb b/lib/xlsxtream/io/zip_tricks.rb index 8795d38..64cfce8 100644 --- a/lib/xlsxtream/io/zip_tricks.rb +++ b/lib/xlsxtream/io/zip_tricks.rb @@ -5,6 +5,7 @@ module IO class ZipTricks def initialize(body) @streamer = ::ZipTricks::Streamer.new(body) + @wf = nil end def <<(data) diff --git a/lib/xlsxtream/workbook.rb b/lib/xlsxtream/workbook.rb index bcae2b2..3a23be5 100644 --- a/lib/xlsxtream/workbook.rb +++ b/lib/xlsxtream/workbook.rb @@ -48,8 +48,10 @@ def initialize(output, options = {}) @file = File.open(output, 'wb') @io = IO::ZipTricks.new(@file) elsif output.respond_to? :add_file + @file = nil @io = output else + @file = nil @io = IO::ZipTricks.new(output) end @sst = SharedStringTable.new