Class: Rack::Deflater::GzipStream

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

Instance Method Summary (collapse)

Constructor Details

- (GzipStream) initialize(body, mtime)

Returns a new instance of GzipStream



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

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

Instance Method Details

- (void) each(&block)



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'rack/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

- (void) write(data)



87
88
89
# File 'rack/rack/deflater.rb', line 87

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