Class: Zip::Deflater
- Inherits:
-
Compressor
- Object
- Compressor
- Zip::Deflater
- Defined in:
- lib/amp/dependencies/zip/zip.rb
Overview
:nodoc:all
Instance Attribute Summary collapse
-
#crc ⇒ Object
readonly
Returns the value of attribute crc.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #<<(data) ⇒ Object
- #finish ⇒ Object
-
#initialize(outputStream, level = Zlib::DEFAULT_COMPRESSION) ⇒ Deflater
constructor
A new instance of Deflater.
Constructor Details
#initialize(outputStream, level = Zlib::DEFAULT_COMPRESSION) ⇒ Deflater
Returns a new instance of Deflater.
1073 1074 1075 1076 1077 1078 1079 |
# File 'lib/amp/dependencies/zip/zip.rb', line 1073 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
#crc ⇒ Object (readonly)
Returns the value of attribute crc.
1094 1095 1096 |
# File 'lib/amp/dependencies/zip/zip.rb', line 1094 def crc @crc end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
1094 1095 1096 |
# File 'lib/amp/dependencies/zip/zip.rb', line 1094 def size @size end |
Instance Method Details
#<<(data) ⇒ Object
1081 1082 1083 1084 1085 1086 |
# File 'lib/amp/dependencies/zip/zip.rb', line 1081 def << (data) val = data.to_s @crc = Zlib::crc32(val, @crc) @size += val.size @outputStream << @zlibDeflater.deflate(data) end |
#finish ⇒ Object
1088 1089 1090 1091 1092 |
# File 'lib/amp/dependencies/zip/zip.rb', line 1088 def finish until @zlibDeflater.finished? @outputStream << @zlibDeflater.finish end end |