Class: Ciinabox::Util::ZipFileGenerator
- Inherits:
-
Object
- Object
- Ciinabox::Util::ZipFileGenerator
- Defined in:
- ext/zip_helper.rb
Overview
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.
12 13 14 15 |
# File 'ext/zip_helper.rb', line 12 def initialize(input_dir, output_file) @input_dir = input_dir @output_file = output_file end |
Instance Method Details
#write ⇒ Object
Zip the input directory.
18 19 20 21 22 23 24 |
# File 'ext/zip_helper.rb', line 18 def write entries = Dir.entries(@input_dir) - %w(. ..) ::Zip::File.open(@output_file, ::Zip::File::CREATE) do |zipfile| write_entries entries, '', zipfile end end |