Class: SheetFiller::Packager
- Inherits:
-
Object
- Object
- SheetFiller::Packager
- Defined in:
- lib/sheet_filler/packager.rb
Class Method Summary collapse
Class Method Details
.get_zipfile_name ⇒ Object
17 18 19 20 21 |
# File 'lib/sheet_filler/packager.rb', line 17 def self.get_zipfile_name zipfile_name = "/tmp/fichas_#{Time.now.to_i}.zip" File.delete(zipfile_name) if File.exists? zipfile_name zipfile_name end |
.pack(files) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/sheet_filler/packager.rb', line 5 def self.pack(files) zipfile_name = get_zipfile_name Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| files.each do |file| filename = File.basename(file) zipfile.add(filename, file) end end files.each { |file| File.delete(file) } zipfile_name end |