Class: HTTPX::Transcoder::Deflate::Deflater

Inherits:
HTTPX::Transcoder::Deflater show all
Defined in:
lib/httpx/transcoder/deflate.rb

Instance Attribute Summary

Attributes inherited from HTTPX::Transcoder::Deflater

#content_type

Instance Method Summary collapse

Methods inherited from HTTPX::Transcoder::Deflater

#bytesize, #close, #initialize, #read, #rewind

Constructor Details

This class inherits a constructor from HTTPX::Transcoder::Deflater

Instance Method Details

#deflate(chunk) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/httpx/transcoder/deflate.rb', line 10

def deflate(chunk)
  @deflater ||= Zlib::Deflate.new

  if chunk.nil?
    unless @deflater.closed?
      last = @deflater.finish
      @deflater.close
      last.empty? ? nil : last
    end
  else
    @deflater.deflate(chunk)
  end
end