Class: Squib::DSL::SaveSheet

Inherits:
Object
  • Object
show all
Includes:
WarnUnexpectedParams
Defined in:
lib/squib/dsl/save_sheet.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) ⇒ SaveSheet

Returns a new instance of SaveSheet.



23
24
25
26
# File 'lib/squib/dsl/save_sheet.rb', line 23

def initialize(deck, dsl_method)
  @deck = deck
  @dsl_method = dsl_method
end

Instance Attribute Details

#deckObject (readonly)



21
22
23
# File 'lib/squib/dsl/save_sheet.rb', line 21

def deck
  @deck
end

#dsl_methodObject (readonly)



21
22
23
# File 'lib/squib/dsl/save_sheet.rb', line 21

def dsl_method
  @dsl_method
end

Class Method Details

.accepted_paramsObject



28
29
30
31
32
33
34
35
# File 'lib/squib/dsl/save_sheet.rb', line 28

def self.accepted_params
  %i(
    range sprue
    columns rows rtl
    dir prefix count_format suffix
    margin gap trim trim_radius rotate
   )
end

Instance Method Details

#run(opts) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/squib/dsl/save_sheet.rb', line 37

def run(opts)
  warn_if_unexpected opts
  range = Args.extract_range opts, deck
  batch = Args.extract_save_batch opts, deck
  sheet = Args.extract_sheet opts, deck, { margin: 0 }
  sprue_file = Args.extract_sprue_file opts, deck
  if sprue_file.sprue.nil?
    deck.render_sheet(range, batch, sheet)
  else
    tmpl = Sprue.load sprue_file.sprue, deck.dpi, deck.cell_px
    Graphics::SaveSpruePNG.new(deck, tmpl, sheet).render_sheet(range)
  end

end