Class: HTTPX::Transcoder::GZIP::Deflater
- Defined in:
- lib/httpx/transcoder/gzip.rb
Instance Attribute Summary
Attributes inherited from Deflater
Instance Method Summary collapse
- #deflate(chunk) ⇒ Object
-
#initialize(body) ⇒ Deflater
constructor
A new instance of Deflater.
Methods inherited from Deflater
Constructor Details
#initialize(body) ⇒ Deflater
Returns a new instance of Deflater.
12 13 14 15 |
# File 'lib/httpx/transcoder/gzip.rb', line 12 def initialize(body) @compressed_chunk = "".b super end |
Instance Method Details
#deflate(chunk) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/httpx/transcoder/gzip.rb', line 17 def deflate(chunk) @deflater ||= Zlib::GzipWriter.new(self) if chunk.nil? unless @deflater.closed? @deflater.flush @deflater.close compressed_chunk end else @deflater.write(chunk) compressed_chunk end end |