File Compressor

File Compressor


Being able to effectively compress a file is a serious asset when you start talking about data storage. The more efficient the compression, the more information can be stored in the same amount of space. There are two popular Ruby compression libraries in use today. The first is ruby-zlib, and the second is rubyzip. Both have their advantages and disadvantages, and I'll leave it to you to choose a compression algorithm that fits your purpose. I will be using rubyzip in the following script.

The Code

 require 'zip/zip'

 unless ARGV[0] puts "Usage: ruby compress.rb <filename.ext>" puts "Example: ruby compress.rb ...

Get Wicked Cool Ruby Scripts now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.