Class: Rack::Deflater::GzipStream

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/deflater.rb

Instance Method Summary collapse

Constructor Details

#initialize(body, mtime) ⇒ GzipStream

Returns a new instance of GzipStream.



54
55
56
57
# File 'lib/rack/deflater.rb', line 54

def initialize(body, mtime)
  @body = body
  @mtime = mtime
end

Instance Method Details

#each(&block) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/rack/deflater.rb', line 59

def each(&block)
  @writer = block
  gzip  =::Zlib::GzipWriter.new(self)
  gzip.mtime = @mtime
  @body.each { |part| gzip.write(part) }
  @body.close if @body.respond_to?(:close)
  gzip.close
  @writer = nil
end

#write(data) ⇒ Object



69
70
71
# File 'lib/rack/deflater.rb', line 69

def write(data)
  @writer.call(data)
end