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
#bytesize, #close, #read, #rewind
Constructor Details
#initialize(body) ⇒ Deflater
Returns a new instance of Deflater.
9 10 11 12 |
# File 'lib/httpx/transcoder/gzip.rb', line 9 def initialize(body) @compressed_chunk = "".b super end |
Instance Method Details
#deflate(chunk) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/httpx/transcoder/gzip.rb', line 14 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 |