class Rack::Deflater::GzipStream - rack-1.6.4 Documentation

# class Rack::Deflater::GzipStream

### Public Class Methods

new(body, mtime) click to toggle source

    # File lib/rack/deflater.rb, line 74
    def initialize(body, mtime)
      @body = body
      @mtime = mtime
      @closed = false
    end

### Public Instance Methods

close() click to toggle source

    # File lib/rack/deflater.rb, line 97
    def close
      return if @closed
      @closed = true
      @body.close if @body.respond_to?(:close)
    end

each(&block) click to toggle source

    # File lib/rack/deflater.rb, line 80
    def each(&block)
      @writer = block
      gzip  =::Zlib::GzipWriter.new(self)
      gzip.mtime = @mtime
      @body.each { |part|
        gzip.write(part)
        gzip.flush
      }
    ensure
      gzip.close
      @writer = nil
    end

write(data) click to toggle source

    # File lib/rack/deflater.rb, line 93
    def write(data)
      @writer.call(data)
    end