Class: ZipFileGenerator
- Inherits:
-
Object
- Object
- ZipFileGenerator
- Defined in:
- lib/atk/zip.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/atk/zip.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/atk/zip.rb', line 11 def write entries = Dir.entries(@input_dir) - %w[. ..] Zip::ZipFile.open(@output_file, Zip::ZipFile::CREATE) do |zipfile| write_entries entries, '', zipfile end end |