From: Markus Fischer Date: 2011-06-14T01:15:22+09:00 Subject: Re: Hi rubies Hi, On 13.06.2011 18:00, medarkness arkness wrote: > I'm new on the block (mailing list & ruby). Welcome :-) > I have some questions: > 1) I'm trying to compress a file using gzip, which library is more suitable for this? I think you will be fine with the zlib library, see http://www.ruby-doc.org/stdlib/libdoc/zlib/rdoc/index.html for documentation. Here's a short example using irb: $ irb Welcome to IRB. You are using ruby 1.9.2p180 (2011-02-18) [i686-linux]. Have fun ;) >> open('test.txt').read #=> "This is a simple test\n" >> require 'zlib' #=> true >> Zlib::GzipWriter.open('test.txt.gz') { |gz| gz.write open('test.txt').read } #=> 22 >> open('test.txt.gz').read => "\u001F\x8B\b\u0000\x827\xF6M\u0000\u0003\v\xC9\xC8,V\u0000\xA2D\x85\xE2\xCC܂\x9CT\x85\x92\xD4\xE2\u0012.\u0000\x84\xC1\u0012F\u0016\u0000\u0000\u0000" >> Zlib::GzipReader.open('test.txt.gz').read #=> "This is a simple test\n" >> cheers, - Markus