Class: Squib::DSL::SavePDF

Inherits:
Object
  • Object
show all
Includes:
WarnUnexpectedParams
Defined in:
lib/squib/dsl/save_pdf.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from WarnUnexpectedParams

#warn_if_unexpected

Constructor Details

#initialize(deck, dsl_method) ⇒ SavePDF

Returns a new instance of SavePDF.



18
19
20
21
22
# File 'lib/squib/dsl/save_pdf.rb', line 18

def initialize(deck, dsl_method)
  @deck = deck
  @dsl_method = dsl_method
  @bar = deck.progress_bar
end

Instance Attribute Details

#deckObject (readonly)



16
17
18
# File 'lib/squib/dsl/save_pdf.rb', line 16

def deck
  @deck
end

#dsl_methodObject (readonly)



16
17
18
# File 'lib/squib/dsl/save_pdf.rb', line 16

def dsl_method
  @dsl_method
end

Class Method Details

.accepted_paramsObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/squib/dsl/save_pdf.rb', line 24

def self.accepted_params
  %i(
    file dir sprue
    width height margin gap
    crop_marks crop_stroke_color crop_stroke_dash crop_stroke_width
    crop_margin_bottom crop_margin_left crop_margin_right crop_margin_top
    rtl trim trim_radius
    range
   )
end

Instance Method Details

#run(opts) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/squib/dsl/save_pdf.rb', line 35

def run(opts)
  warn_if_unexpected opts
  range = Args.extract_range opts, deck
  sheet = Args.extract_sheet opts, deck
  sprue_file = Args.extract_sprue_file opts, deck
  if sprue_file.sprue.nil?
    Graphics::SavePDF.new(deck).render_pdf(range, sheet)
  else
    tmpl = Sprue.load sprue_file.sprue, deck.dpi, deck.cell_px
    Graphics::SaveSpruePDF.new(deck, tmpl, sheet).render_sheet(range)
  end

end