Class: Ccrypto::Ruby::Decompression
- Inherits:
-
Object
- Object
- Ccrypto::Ruby::Decompression
- Defined in:
- lib/ccrypto/ruby/engines/decompression_engine.rb
Instance Method Summary collapse
- #final ⇒ Object
-
#initialize(*args, &block) ⇒ Decompression
constructor
A new instance of Decompression.
- #update(val) ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ Decompression
Returns a new instance of Decompression.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ccrypto/ruby/engines/decompression_engine.rb', line 7 def initialize(*args, &block) if block outPath = block.call(:out_path) if is_empty?(outPath) outFile = block.call(:out_file) raise CompressionError, "Given out_file required to support write() call" if not outFile.respond_to?(:write) @out = outFile else @out = Tempfile.new(SecureRandom.hex(16)) end @intBufSize = block.call(:int_buf_size) || 102400 else @intBufSize = 102400 end @eng = Zlib::Inflate.new #@in = Tempfile.new(SecureRandom.hex(16)) end |
Instance Method Details
#final ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ccrypto/ruby/engines/decompression_engine.rb', line 38 def final #eng = Zlib::Inflate.new #@in.seek(0) #intBuf = false #if @out.nil? # @out = StringIO.new # intBuf = true #end #chunk = 102400 #loop do # compressed = @in.read(chunk) # res = eng.inflate(compressed) #, Zlib::SYNC_FLUSH) # @out.write(res) # break if @in.eof? #end #if intBuf # @out.string #else # @out #end end |
#update(val) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/ccrypto/ruby/engines/decompression_engine.rb', line 31 def update(val) begin @eng.inflate(val) rescue Zlib::DataError end end |