Class: Rubko::Asset::GzipStream
- Inherits:
-
Object
- Object
- Rubko::Asset::GzipStream
- Defined in:
- lib/rubko/asset/gzipStream.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(body, mtime = Time.now) ⇒ GzipStream
constructor
A new instance of GzipStream.
- #write(data) ⇒ Object
Constructor Details
#initialize(body, mtime = Time.now) ⇒ GzipStream
Returns a new instance of GzipStream.
6 7 8 9 10 |
# File 'lib/rubko/asset/gzipStream.rb', line 6 def initialize(body, mtime = Time.now) @body = body @gzip = Zlib::GzipWriter.new self @gzip.mtime = mtime end |
Instance Method Details
#each(&block) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/rubko/asset/gzipStream.rb', line 12 def each(&block) @writer = block @body.each { |part| @gzip.write part @gzip.flush } ensure @gzip.close end |
#write(data) ⇒ Object
22 23 24 |
# File 'lib/rubko/asset/gzipStream.rb', line 22 def write(data) @writer.call data end |