Sha256: f7e7e47b315f7660b358436d1b0b58cc46a63661dc160afd76b2d816b86f0648

Contents?: true

Size: 607 Bytes

Versions: 3

Compression:

Stored size: 607 Bytes

Contents

require 'zlib'
require 'lzoruby'

module GZIP
  def self.compress string, level
    z = Zlib::Deflate.new level
    dst = z.deflate string, Zlib::FINISH
    z.close
    dst
  end
  
  def self.decompress string
    zstream = Zlib::Inflate.new
    buf = zstream.inflate string
    zstream.finish
    zstream.close
    buf
  end
end

class Archive
  attr_reader :type

  def initialize type
    puts_fail "Unsupported type" unless [:lzo, :gzip].include? type.downcase
    instance_eval %{@type = #{type.to_s.upcase}}
  end
  
  def method_missing name, *args
    StringIO.new @type.send(name, *args)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
encbs-0.2.1 lib/archive.rb
encbs-0.2.1.beta2 lib/archive.rb
encbs-0.2.1.beta1 lib/archive.rb