Sha256: 4d3fdc7e9012ef798dc80cb803499c4c9b65b9af9543da88a67b85e38a67ebd3

Contents?: true

Size: 591 Bytes

Versions: 2

Compression:

Stored size: 591 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
    fail "Error" 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

2 entries across 2 versions & 1 rubygems

Version Path
encbs-0.2.1.alpha lib/archive.rb
encbs-0.2.0.alpha lib/archive.rb