Class: Rack::Compress::Deflater::BrotliStream
- Inherits:
-
Object
- Object
- Rack::Compress::Deflater::BrotliStream
- Includes:
- Utils
- Defined in:
- lib/rack/compress/deflater.rb
Instance Method Summary collapse
- #close ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(body, level) ⇒ BrotliStream
constructor
A new instance of BrotliStream.
Constructor Details
#initialize(body, level) ⇒ BrotliStream
Returns a new instance of BrotliStream.
76 77 78 79 |
# File 'lib/rack/compress/deflater.rb', line 76 def initialize(body, level) @body = body @level = level end |
Instance Method Details
#close ⇒ Object
96 97 98 |
# File 'lib/rack/compress/deflater.rb', line 96 def close @body.close if @body.respond_to?(:close) end |
#each(&block) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/rack/compress/deflater.rb', line 81 def each(&block) @writer = block # Use String.new instead of '' to support environments with strings frozen by default. buffer = String.new @body.each do |part| buffer << part end # TODO: implement Brotli using streaming classes yield ::Brotli.deflate(buffer, { quality: @level }) ensure @writer = nil end |