Class: OutwoodLabels::Generate
- Inherits:
-
Object
- Object
- OutwoodLabels::Generate
- Includes:
- Callable
- Defined in:
- lib/outwood_labels/generate.rb
Instance Method Summary collapse
-
#call ⇒ Object
Generate PDF and write to disk.
-
#initialize(data, outfile, template, config = {}) ⇒ Generate
constructor
A new instance of Generate.
Methods included from Callable
Constructor Details
#initialize(data, outfile, template, config = {}) ⇒ Generate
Returns a new instance of Generate.
13 14 15 16 17 18 |
# File 'lib/outwood_labels/generate.rb', line 13 def initialize(data, outfile, template, config = {}) @config = config @data = data @outfile = outfile @template = template end |
Instance Method Details
#call ⇒ Object
Generate PDF and write to disk
22 23 24 25 26 27 |
# File 'lib/outwood_labels/generate.rb', line 22 def call check_header if @template config = @config.merge({ layout: @template.layout }) labels = Prawn::LabelSheet.new @data, **config, &@template.method(:evaluate) labels.document.render_file(@outfile) end |