Class: Rack::Deflater::GzipStream
- Inherits:
-
Object
- Object
- Rack::Deflater::GzipStream
- Defined in:
- lib/rack/deflater.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(body, mtime) ⇒ GzipStream
constructor
A new instance of GzipStream.
- #write(data) ⇒ Object
Constructor Details
#initialize(body, mtime) ⇒ GzipStream
Returns a new instance of GzipStream.
68 69 70 71 |
# File 'lib/rack/deflater.rb', line 68 def initialize(body, mtime) @body = body @mtime = mtime end |
Instance Method Details
#each(&block) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/rack/deflater.rb', line 73 def each(&block) @writer = block gzip =::Zlib::GzipWriter.new(self) gzip.mtime = @mtime @body.each { |part| gzip.write(part) gzip.flush } ensure @body.close if @body.respond_to?(:close) gzip.close @writer = nil end |
#write(data) ⇒ Object
87 88 89 |
# File 'lib/rack/deflater.rb', line 87 def write(data) @writer.call(data) end |