Class: Rant::Archive::Rubyzip::Deflater
- Inherits:
-
Compressor
- Object
- Compressor
- Rant::Archive::Rubyzip::Deflater
- Defined in:
- lib/rant/archive/rubyzip.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.
767 768 769 770 771 772 773 |
# File 'lib/rant/archive/rubyzip.rb', line 767 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.
788 789 790 |
# File 'lib/rant/archive/rubyzip.rb', line 788 def crc @crc end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
788 789 790 |
# File 'lib/rant/archive/rubyzip.rb', line 788 def size @size end |
Instance Method Details
#<<(data) ⇒ Object
775 776 777 778 779 780 |
# File 'lib/rant/archive/rubyzip.rb', line 775 def << (data) val = data.to_s @crc = Zlib::crc32(val, @crc) @size += val.size @outputStream << @zlibDeflater.deflate(data) end |
#finish ⇒ Object
782 783 784 785 786 |
# File 'lib/rant/archive/rubyzip.rb', line 782 def finish until @zlibDeflater.finished? @outputStream << @zlibDeflater.finish end end |