Class: Rant::Archive::Rubyzip::Deflater

Inherits:
Compressor show all
Defined in:
lib/rant/archive/rubyzip.rb

Overview

:nodoc:all

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#crcObject (readonly)

Returns the value of attribute crc


788
789
790
# File 'lib/rant/archive/rubyzip.rb', line 788

def crc
  @crc
end

#sizeObject (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

#finishObject


782
783
784
785
786
# File 'lib/rant/archive/rubyzip.rb', line 782

def finish
  until @zlibDeflater.finished?
	@outputStream << @zlibDeflater.finish
  end
end