Sha256: 82a536c4fef1f4677e35f6ab146f56b3a686684d0598b76602dba0f9253dfd9a

Contents?: true

Size: 927 Bytes

Versions: 3

Compression:

Stored size: 927 Bytes

Contents

require 'zlib'

module CcipherFactory
  module Compression
    module ZlibCompressor
      include CcipherFactory::Common

      def compress_init(*args, &block)

        @compressor = Ccrypto::UtilFactory.instance(:compression, Ccrypto::CompressionConfig.new)
        #@compressor = Zlib::Deflate.new

        if block
          instance_eval(&block)
          compress_final
        else
          self
        end

      end

      def compress_update(val)
        res = @compressor.update(val)
        #res = @compressor.deflate(val, Zlib::SYNC_FLUSH)
        write_to_output(res)
        res
      end

      def compress_final
        @compressor.final

        ts = BinStruct.instance.struct(:compression_zlib)
        ts.encoded
      end

      private
      def logger
        if @logger.nil?
          @logger = Tlogger.new
          @logger.tag = :zlibComp
        end
        @logger
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ccipher_factory-0.1.2 lib/ccipher_factory/compression/zlib_compressor.rb
ccipher_factory-0.1.1 lib/ccipher_factory/compression/zlib_compressor.rb
ccipher_factory-0.1.0 lib/ccipher_factory/compression/zlib_compressor.rb