Class: Rack::Deflater::GzipStream

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

Instance Method Summary collapse

Constructor Details

#initialize(body, mtime) ⇒ GzipStream

Returns a new instance of GzipStream.



68
69
70
71
# File 'lib/vendor/rack-1.5.2/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/vendor/rack-1.5.2/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/vendor/rack-1.5.2/lib/rack/deflater.rb', line 87

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