Class: Harbor::ZippedIO::Deflater
- Inherits:
-
Object
- Object
- Harbor::ZippedIO::Deflater
- Defined in:
- lib/harbor/zipped_io.rb
Instance Attribute Summary collapse
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
-
#initialize(file, level = 0) ⇒ Deflater
constructor
A new instance of Deflater.
- #read ⇒ Object
Constructor Details
#initialize(file, level = 0) ⇒ Deflater
Returns a new instance of Deflater.
65 66 67 68 |
# File 'lib/harbor/zipped_io.rb', line 65 def initialize(file, level = 0) @file = file @zlibDeflater = Zlib::Deflate.new(level, -Zlib::MAX_WBITS) end |
Instance Attribute Details
#size ⇒ Object
Returns the value of attribute size.
63 64 65 |
# File 'lib/harbor/zipped_io.rb', line 63 def size @size end |
Instance Method Details
#read ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/harbor/zipped_io.rb', line 70 def read @file.rewind while data = @file.read(Harbor::ZippedIO::block_size) yield @zlibDeflater.deflate(data) end until @zlibDeflater.finished? yield @zlibDeflater.finish end nil end |