Class: Squib::DSL::SavePNG

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

Returns a new instance of SavePNG.



18
19
20
21
22
# File 'lib/squib/dsl/save_png.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_png.rb', line 16

def deck
  @deck
end

#dsl_methodObject (readonly)



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

def dsl_method
  @dsl_method
end

Class Method Details

.accepted_paramsObject



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

def self.accepted_params
  %i(
    range
    dir prefix suffix count_format
    rotate trim trim_radius
    shadow_offset_x shadow_offset_y shadow_radius shadow_color shadow_trim
   )
end

Instance Method Details

#run(opts) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/squib/dsl/save_png.rb', line 33

def run(opts)
  warn_if_unexpected opts
  range = Args.extract_range opts, deck
  batch = Args.extract_save_batch opts, deck
  shadow = Args.extract_drop_shadow opts, deck
  @bar.start("Saving PNGs to #{batch.summary}", deck.size) do |bar|
    range.map do |i|
      deck.cards[i].save_png(batch[i], shadow[i])
      bar.increment
    end
  end
end