Module: PDFGen::Composite

Included in:
Div, Document, Span
Defined in:
lib/modules/composite.rb

Instance Method Summary collapse

Instance Method Details

#[](index) ⇒ Object



9
10
11
# File 'lib/modules/composite.rb', line 9

def [](index)
  regions[index]
end

#add_region(region) ⇒ Object

adds new region to the span



33
34
35
# File 'lib/modules/composite.rb', line 33

def add_region region
  regions << region if region
end

#apply_values(values = {}) ⇒ Object

applies specified values



22
23
24
# File 'lib/modules/composite.rb', line 22

def apply_values(values = {})
  regions.each{|region| region.apply_values values}
end

#elements(style = {}, &initialization_block) ⇒ Object

executes specified initialization block on all inner regions



14
15
16
17
18
19
# File 'lib/modules/composite.rb', line 14

def elements(style = {}, &initialization_block)
  regions.each do |region|
    region.set_properties style unless style.nil?
    region.instance_eval(&initialization_block) if initialization_block
  end
end

#page_pad_top=(value) ⇒ Object



26
27
28
29
30
# File 'lib/modules/composite.rb', line 26

def page_pad_top=(value)
  super

  regions.each {|region| region.page_pad_top=value}
end

#regionsObject



5
6
7
# File 'lib/modules/composite.rb', line 5

def regions
  @regions ||= []
end

#render(pos, av_height, test = false) ⇒ Object

renders specified span at the specified position returns real position that caption was generated on



43
44
45
46
47
48
49
50
# File 'lib/modules/composite.rb', line 43

def render(pos,av_height, test = false)
  if av_height >= self.height
    render_regions(pos[0],pos[1], test)
    [self.height, true]
  else
    [0, false]
  end
end

#render_regions(x, y, test = false) ⇒ Object



37
38
39
# File 'lib/modules/composite.rb', line 37

def render_regions(x, y, test = false)
  regions.each { |region| region.render([x, document.pdf.y], document.pdf.y, test)}
end