class Threatinator::Decoders::Gzip
Public Instance Methods
decode(io)
click to toggle source
Decompresses the io using Gzip
. @param (see Threatinator::Decoder#decode
)
# File lib/threatinator/decoders/gzip.rb, line 12 def decode(io) zio = Zlib::GzipReader.new(io, encoding: "binary") tempfile = Tempfile.new("threatinator", encoding: "binary") while chunk = zio.read(10240) tempfile.write(chunk) end zio.close io.close unless io.closed? tempfile.rewind tempfile.set_encoding(self.encoding) tempfile rescue Zlib::GzipFile::Error => e raise Threatinator::Exceptions::DecoderError.new end