Class: Plum::Decoders::Deflate

Inherits:
Base
  • Object
show all
Defined in:
lib/plum/client/decoders.rb

Overview

‘deflate` is not just deflate, wrapped by zlib format (RFC 1950)

Instance Method Summary collapse

Constructor Details

#initializeDeflate

Returns a new instance of Deflate.



14
15
16
# File 'lib/plum/client/decoders.rb', line 14

def initialize
  @inflate = Zlib::Inflate.new(Zlib::MAX_WBITS)
end

Instance Method Details

#decode(chunk) ⇒ Object



18
19
20
21
22
# File 'lib/plum/client/decoders.rb', line 18

def decode(chunk)
  @inflate.inflate(chunk)
rescue Zlib::Error => e
  raise DecoderError.new("failed to decode chunk", e)
end

#finishObject



24
25
26
27
28
# File 'lib/plum/client/decoders.rb', line 24

def finish
  @inflate.finish
rescue Zlib::Error => e
  raise DecoderError.new("failed to finalize", e)
end