Skip to content

Instantly share code, notes, and snippets.

@nahi
Created October 27, 2011 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nahi/1318550 to your computer and use it in GitHub Desktop.
Save nahi/1318550 to your computer and use it in GitHub Desktop.
require 'zlib'
class MyInflate
def initialize(input)
@z = Zlib::Inflate.new
@input = input
@buf = ''
end
def read(n)
while !@z.finished? && @buf.size < n
@buf << @z.inflate(@input.slice!(0, n))
end
@buf.slice!(0, n)
end
end
compressed = Zlib::Deflate.deflate("0" * 1024 * 1024)
z = MyInflate.new(compressed)
p z.read(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment