Class: Omnizip::Algorithms::Deflate::Decoder

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/omnizip/algorithms/deflate/decoder.rb

Overview

Deflate decoder using Zlib

This class wraps Ruby's Zlib::Inflate to provide Deflate decompression following the established Omnizip architecture.

Constant Summary

Constants included from Constants

Constants::BEST_COMPRESSION, Constants::BEST_SPEED, Constants::BUFFER_SIZE, Constants::DEFAULT_COMPRESSION, Constants::DEFAULT_STRATEGY, Constants::FILTERED, Constants::FIXED, Constants::HUFFMAN_ONLY, Constants::NO_COMPRESSION, Constants::RLE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_stream) ⇒ Decoder

Initialize decoder

Parameters:

  • input_stream (IO)

    Input stream of compressed data



20
21
22
# File 'lib/omnizip/algorithms/deflate/decoder.rb', line 20

def initialize(input_stream)
  @input_stream = input_stream
end

Instance Attribute Details

#input_streamObject (readonly)

Returns the value of attribute input_stream.



15
16
17
# File 'lib/omnizip/algorithms/deflate/decoder.rb', line 15

def input_stream
  @input_stream
end

Instance Method Details

#decode_streamString

Decode compressed data stream

Returns:

  • (String)

    Decompressed data



27
28
29
30
31
32
33
# File 'lib/omnizip/algorithms/deflate/decoder.rb', line 27

def decode_stream
  compressed = @input_stream.read
  inflater = Zlib::Inflate.new
  decompressed = inflater.inflate(compressed)
  inflater.close
  decompressed
end