class Rack::Deflater::DeflateStream

Constants

DEFLATE_ARGS

Public Class Methods

new(body) click to toggle source
# File lib/rack/deflater.rb, line 113
def initialize(body)
  @body = body
  @closed = false
end

Public Instance Methods

close() click to toggle source
# File lib/rack/deflater.rb, line 127
def close
  return if @closed
  @closed = true
  @body.close if @body.respond_to?(:close)
end
each() { |deflate(part, SYNC_FLUSH)| ... } click to toggle source
# File lib/rack/deflater.rb, line 118
def each
  deflator = ::Zlib::Deflate.new(*DEFLATE_ARGS)
  @body.each { |part| yield deflator.deflate(part, Zlib::SYNC_FLUSH) }
  yield fin = deflator.finish
ensure
  deflator.finish unless fin
  deflator.close
end