LZF/Ruby

http://storehouse.sakura.ne.jp/viewvc/viewvc.cgi/lzfruby/?root=svn
とりあえずできた。

require 'lzfruby'
require 'stringio'

source = StringIO.new(open('foo.txt') {|f| f.read })

puts "uncompress size: #{source.length}"

# compress
comp_data = StringIO.new
LZF.compress(source, comp_data)
puts "compress size: #{comp_data.length}"

# decompress
comp_data.seek(0)
decomp_data = StringIO.new
LZF.decompress(comp_data, decomp_data)
puts "decompress size: #{decomp_data.length}"
puts "decompress success?: #{source.string == decomp_data.string}"