File Compressor

File Compressor

compress.rb

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 books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.