require 'zlib'file = 'compressed.gz'Zlib::GzipWriter.open(file) do |gzip| gzip << "this is a test." gzip.closeendopen(file, 'rb') { |f| f.read(10) }Zlib::GzipReader.open(file) { |gzip| puts gzip.read }