Class: Threatinator::Decoders::Gzip
- Inherits:
-
Threatinator::Decoder
- Object
- Threatinator::Decoder
- Threatinator::Decoders::Gzip
- Defined in:
- lib/threatinator/decoders/gzip.rb
Instance Attribute Summary
Attributes inherited from Threatinator::Decoder
Instance Method Summary collapse
-
#decode(io) ⇒ Object
Decompresses the io using Gzip.
Methods inherited from Threatinator::Decoder
Constructor Details
This class inherits a constructor from Threatinator::Decoder
Instance Method Details
#decode(io) ⇒ Object
Decompresses the io using Gzip.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# 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 |