Class: Postdoc::Batch
- Inherits:
-
Object
- Object
- Postdoc::Batch
- Defined in:
- lib/postdoc/batch.rb
Overview
This module represents a batch. At times we want to render multiple PDF’s in series and batching saves a lot of overhead by not restarting chrome over and over. Practical applications are “stitching” PDF’s together to get around markup constraints in chrome or rendering a batch of reports all at once.
Instance Method Summary collapse
-
#add_document(document, settings: {}) ⇒ Object
Creates a job from a document and add to the jobs.
- #add_job(job) ⇒ Object
- #cleanup ⇒ Object
-
#initialize(jobs: []) ⇒ Batch
constructor
A new instance of Batch.
-
#result(client) ⇒ Object
returns the output of the config.
Constructor Details
#initialize(jobs: []) ⇒ Batch
Returns a new instance of Batch.
11 12 13 |
# File 'lib/postdoc/batch.rb', line 11 def initialize(jobs: []) @jobs = jobs end |
Instance Method Details
#add_document(document, settings: {}) ⇒ Object
Creates a job from a document and add to the jobs.
16 17 18 19 |
# File 'lib/postdoc/batch.rb', line 16 def add_document(document, settings: {}) settings = PrintSettings.new(**settings) @jobs << Job.new(document, settings: settings) end |
#add_job(job) ⇒ Object
21 22 23 |
# File 'lib/postdoc/batch.rb', line 21 def add_job(job) @jobs << job end |
#cleanup ⇒ Object
30 31 32 |
# File 'lib/postdoc/batch.rb', line 30 def cleanup @jobs.each(&:cleanup) end |
#result(client) ⇒ Object
returns the output of the config. Requires a Client
26 27 28 |
# File 'lib/postdoc/batch.rb', line 26 def result(client) @jobs.map { |job| job.result(client) } end |