Text compressor in ruby