Class: Squib::DSL::PNG

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

Returns a new instance of PNG.



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

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

Instance Attribute Details

#deckObject (readonly)



18
19
20
# File 'lib/squib/dsl/png.rb', line 18

def deck
  @deck
end

#dsl_methodObject (readonly)



18
19
20
# File 'lib/squib/dsl/png.rb', line 18

def dsl_method
  @dsl_method
end

Class Method Details

.accepted_paramsObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/squib/dsl/png.rb', line 25

def self.accepted_params
  %i(
    file
    x y width height
    alpha blend mask angle
    crop_x crop_y crop_width crop_height
    crop_corner_radius crop_corner_x_radius crop_corner_y_radius
    flip_horizontal flip_vertical
    range layout
    placeholder
   )
end

Instance Method Details

#run(opts) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/squib/dsl/png.rb', line 38

def run(opts)
  warn_if_unexpected opts
  Dir.chdir(deck.img_dir) do
    range = Args.extract_range opts, deck
    paint = Args.extract_paint opts, deck
    box   = Args.extract_scale_box opts, deck
    trans = Args.extract_transform opts, deck
    ifile = Args.extract_input_file opts, deck
    deck.progress_bar.start('Loading PNG(s)', range.size) do |bar|
      range.each do |i|
        deck.cards[i].png(ifile[i].file, box[i], paint[i], trans[i])
        bar.increment
      end
    end
  end

end