Class: FileComposer::Documents::Zip
- Defined in:
- lib/file_composer/documents/zip.rb
Overview
Can compress documents together into a zip file.
Instance Attribute Summary collapse
-
#blueprint ⇒ Object
readonly
Returns the value of attribute blueprint.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(filename:, blueprint: {}) ⇒ Zip
constructor
A new instance of Zip.
- #write!(temp_root = '', store = Stores::Null.new) ⇒ Object
Constructor Details
Instance Attribute Details
#blueprint ⇒ Object (readonly)
Returns the value of attribute blueprint.
16 17 18 |
# File 'lib/file_composer/documents/zip.rb', line 16 def blueprint @blueprint end |
Instance Method Details
#write!(temp_root = '', store = Stores::Null.new) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/file_composer/documents/zip.rb', line 24 def write!(temp_root = '', store = Stores::Null.new) results = blueprint.write!(temp_root) write_time_in_seconds = results.sum(&:time_in_seconds) physical_filename = nil zip_time_in_seconds = Benchmark.measure do physical_filename = zip!(temp_root, results) end.real total_time_in_seconds = write_time_in_seconds + zip_time_in_seconds cleanup(results) final_filename = store.move!(physical_filename) file_result = FileResult.new(filename, final_filename) Result.new(file_result, total_time_in_seconds) end |