Zlibでアーカイビング
正直に言いますが、特にネタが無かったので。アーカイビングって言葉、なんか違和感がありますね。
require "zlib" path = ARGV.shift text = ARGV.shift if text.nil? or text.empty? Zlib::GzipReader.open(path) do |inp| print inp.read end else Zlib::GzipWriter.open(path) do |out| 3.times do |i| out.write "##{i}:#{text}\n" end end end
$ ruby zlibtest.rb test.gz "good day." $ gzip -dc test.gz #0:good day. #1:good day. #2:good day. $ ruby zlibtest.rb test.gz #0:good day. #1:good day. #2:good day. $