From: "Mauricio Fernández" Date: 2004-11-22T18:21:07+09:00 Subject: Re: Zlib::GzipReader/Writer and strings On Mon, Nov 22, 2004 at 02:39:47PM +0900, jim@freeze.org wrote: > Hi > > Is there a way for Zlib::GzipReader or GzipWriter > to read and write to a string as a StringIO object? > > I have tried and am not having any luck. > > I am using Ruby 1.8.1. Just doing Zlib::GzipReader.new(anIO) (where anIO responds to #read with the same semantics as IO) works for me. >> require 'stringio'; require 'zlib' => true >> a = StringIO.new "" => # >> b = Zlib::GzipWriter.new a; b.write("foo"*10); b.finish; a.string => "\037\213\010\000\363\256\241A\000\003K\313\317O\303\215\000\365*\235\350\036\000\000\000" >> a.rewind; c = Zlib::GzipReader.new(a); c.read => "foofoofoofoofoofoofoofoofoofoo" -- Hassle-free packages for Ruby? RPA is available from http://www.rubyarchive.org/