Class: Zip::Deflater
- Inherits:
-
Compressor
- Object
- Compressor
- Zip::Deflater
- Defined in:
- lib/zip/zip.rb
Overview
:nodoc:all
Instance Attribute Summary (collapse)
-
- (Object) crc
readonly
Returns the value of attribute crc.
-
- (Object) size
readonly
Returns the value of attribute size.
Instance Method Summary (collapse)
- - (Object) <<(data)
- - (Object) finish
-
- (Deflater) initialize(outputStream, level = Zlib::DEFAULT_COMPRESSION)
constructor
A new instance of Deflater.
Constructor Details
- (Deflater) initialize(outputStream, level = Zlib::DEFAULT_COMPRESSION)
A new instance of Deflater
1096 1097 1098 1099 1100 1101 1102 |
# File 'lib/zip/zip.rb', line 1096 def initialize(outputStream, level = Zlib::DEFAULT_COMPRESSION) super() @outputStream = outputStream @zlibDeflater = Zlib::Deflate.new(level, -Zlib::MAX_WBITS) @size = 0 @crc = Zlib::crc32 end |
Instance Attribute Details
- (Object) crc (readonly)
Returns the value of attribute crc
1117 1118 1119 |
# File 'lib/zip/zip.rb', line 1117 def crc @crc end |
- (Object) size (readonly)
Returns the value of attribute size
1117 1118 1119 |
# File 'lib/zip/zip.rb', line 1117 def size @size end |
Instance Method Details
- (Object) <<(data)
1104 1105 1106 1107 1108 1109 |
# File 'lib/zip/zip.rb', line 1104 def << (data) val = data.to_s @crc = Zlib::crc32(val, @crc) @size += val.size @outputStream << @zlibDeflater.deflate(data) end |
- (Object) finish
1111 1112 1113 1114 1115 |
# File 'lib/zip/zip.rb', line 1111 def finish until @zlibDeflater.finished? @outputStream << @zlibDeflater.finish end end |