Class: Squib::DSL::Text

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

Returns a new instance of Text.



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

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

Instance Attribute Details

#deckObject (readonly)



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

def deck
  @deck
end

#dsl_methodObject (readonly)



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

def dsl_method
  @dsl_method
end

#embedObject (readonly)



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

def embed
  @embed
end

Class Method Details

.accepted_paramsObject



29
30
31
32
33
34
35
36
37
# File 'lib/squib/dsl/text.rb', line 29

def self.accepted_params
  %i(
    str font font_size x y markup width height
    wrap spacing align justify valign ellipsize angle dash cap join
    hint color fill_color
    stroke_color stroke_width stroke_width stroke_color stroke_strategy
    range layout
  )
end

Instance Method Details

#run(opts) ⇒ Object



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

def run(opts)
  warn_if_unexpected opts
  range = Args.extract_range opts, deck
  para  = Args.extract_para opts, deck
  box   = Args.extract_box opts, deck, { width: :auto, height: :auto }
  trans = Args.extract_transform opts, deck
  draw  = Args.extract_draw opts, deck, { stroke_width: 0.0 }
  extents = Array.new(deck.size)
  range.each do |i|
    extents[i] = deck.cards[i].text(embed, para[i], box[i], trans[i], draw[i], deck.dpi)
  end
  return extents
end