Class: ThousandIsland::Components::Footer

Inherits:
Base
  • Object
show all
Defined in:
lib/thousand_island/components/footer.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #pdf

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#defaults, #draw, #initialize, #render_all

Constructor Details

This class inherits a constructor from ThousandIsland::Components::Base

Class Method Details

.default_numbering_optionsObject



83
84
85
86
87
88
# File 'lib/thousand_island/components/footer.rb', line 83

def self.default_numbering_options
  {
    align: :right,
    start_count_at: 1,
  }
end

.defaultsObject



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/thousand_island/components/footer.rb', line 71

def self.defaults
  {
    height: 33,
    top_padding: 20,
    repeated: true,
    numbering_options: default_numbering_options,
    number_pages: true,
    numbering_string: '<page>',
    style: {},
  }
end

Instance Method Details

#after_renderObject



21
22
23
# File 'lib/thousand_island/components/footer.rb', line 21

def after_render
  col3
end

#box_heightObject



55
56
57
# File 'lib/thousand_island/components/footer.rb', line 55

def box_height
  options[:height]
end

#col1Object



37
38
# File 'lib/thousand_island/components/footer.rb', line 37

def col1
end

#col1_widthObject



25
26
27
# File 'lib/thousand_island/components/footer.rb', line 25

def col1_width
  pdf.bounds.width * 0.15
end

#col2Object



40
41
42
43
44
45
46
# File 'lib/thousand_island/components/footer.rb', line 40

def col2
  start = col1_width
  pdf.bounding_box([start, box_height], width: col2_width, height: box_height) do
    inject_style
    yield if block_given?
  end
end

#col2_widthObject



29
30
31
# File 'lib/thousand_island/components/footer.rb', line 29

def col2_width
  pdf.bounds.width * 0.7
end

#col3Object



48
49
50
51
52
53
# File 'lib/thousand_island/components/footer.rb', line 48

def col3
  start = col1_width + col2_width
  pdf.bounding_box([start, box_height], width: col3_width, height: box_height) do
    pdf.number_pages numbering_string, numbering_options if number_pages?
  end
end

#col3_widthObject



33
34
35
# File 'lib/thousand_island/components/footer.rb', line 33

def col3_width
  pdf.bounds.width * 0.15
end

#inject_styleObject



67
68
69
# File 'lib/thousand_island/components/footer.rb', line 67

def inject_style
  options[:style].each { |k,v| pdf.send(k, v) if pdf.respond_to?(k) } if options[:style]
end

#number_pages?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/thousand_island/components/footer.rb', line 9

def number_pages?
  options[:number_pages]
end

#numbering_optionsObject



59
60
61
# File 'lib/thousand_island/components/footer.rb', line 59

def numbering_options
  options[:style].merge(options[:numbering_options])
end

#numbering_stringObject



5
6
7
# File 'lib/thousand_island/components/footer.rb', line 5

def numbering_string
  options[:numbering_string]
end

#render(&block) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/thousand_island/components/footer.rb', line 13

def render(&block)
  pdf.bounding_box([0, box_height], width: pdf.bounds.width, height: box_height) do
    col1
    col2(&block)
    # col3
  end
end

#repeated?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/thousand_island/components/footer.rb', line 63

def repeated?
  options[:repeated]
end