Class: HTTP::Features::AutoDeflate::CompressedBody
- Inherits:
-
Request::Body
- Object
- Request::Body
- HTTP::Features::AutoDeflate::CompressedBody
- Defined in:
- lib/http/features/auto_deflate.rb
Overview
Base class for compressed request body wrappers
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Request::Body
Instance Method Summary collapse
-
#each(&block) ⇒ self, Enumerator
Yields each chunk of compressed data.
-
#initialize(uncompressed_body) ⇒ CompressedBody
constructor
Initializes a compressed body wrapper.
-
#size ⇒ Integer
Returns the size of the compressed body.
Methods inherited from Request::Body
Constructor Details
#initialize(uncompressed_body) ⇒ CompressedBody
Initializes a compressed body wrapper
105 106 107 108 109 |
# File 'lib/http/features/auto_deflate.rb', line 105 def initialize(uncompressed_body) super(nil) @body = uncompressed_body @compressed = nil end |
Instance Method Details
#each(&block) ⇒ self, Enumerator
Yields each chunk of compressed data
130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/http/features/auto_deflate.rb', line 130 def each(&block) return to_enum(:each) unless block if @compressed compressed_each(&block) else compress(&block) end self end |
#size ⇒ Integer
Returns the size of the compressed body
118 119 120 121 |
# File 'lib/http/features/auto_deflate.rb', line 118 def size compress_all! unless @compressed @compressed.size end |