Class: ZipFileGenerator
- Inherits:
-
Object
- Object
- ZipFileGenerator
- Defined in:
- lib/tasks/zip_file_generator.rb
Instance Method Summary collapse
-
#initialize(input_dir, output_file) ⇒ ZipFileGenerator
constructor
Initialize with the directory to zip and the location of the output archive.
-
#write ⇒ Object
Zip the input directory.
Constructor Details
#initialize(input_dir, output_file) ⇒ ZipFileGenerator
Initialize with the directory to zip and the location of the output archive.
5 6 7 8 |
# File 'lib/tasks/zip_file_generator.rb', line 5 def initialize(input_dir, output_file) @input_dir = input_dir @output_file = output_file end |
Instance Method Details
#write ⇒ Object
Zip the input directory.
11 12 13 14 15 16 17 |
# File 'lib/tasks/zip_file_generator.rb', line 11 def write entries = Dir.entries(@input_dir) - %w(. ..) ::Zip::File.open(@output_file, ::Zip::File::CREATE) do |io| write_entries entries, '', io end end |