Class: ThousandIsland::Components::Footer
- Inherits:
-
Base
- Object
- Base
- ThousandIsland::Components::Footer
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
Class Method Details
.default_numbering_options ⇒ Object
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
|
.defaults ⇒ Object
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_render ⇒ Object
21
22
23
|
# File 'lib/thousand_island/components/footer.rb', line 21
def after_render
col3
end
|
#box_height ⇒ Object
55
56
57
|
# File 'lib/thousand_island/components/footer.rb', line 55
def box_height
options[:height]
end
|
#col1 ⇒ Object
37
38
|
# File 'lib/thousand_island/components/footer.rb', line 37
def col1
end
|
#col1_width ⇒ Object
25
26
27
|
# File 'lib/thousand_island/components/footer.rb', line 25
def col1_width
pdf.bounds.width * 0.15
end
|
#col2 ⇒ Object
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_width ⇒ Object
29
30
31
|
# File 'lib/thousand_island/components/footer.rb', line 29
def col2_width
pdf.bounds.width * 0.7
end
|
#col3 ⇒ Object
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_width ⇒ Object
33
34
35
|
# File 'lib/thousand_island/components/footer.rb', line 33
def col3_width
pdf.bounds.width * 0.15
end
|
#inject_style ⇒ Object
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
9
10
11
|
# File 'lib/thousand_island/components/footer.rb', line 9
def number_pages?
options[:number_pages]
end
|
#numbering_options ⇒ Object
59
60
61
|
# File 'lib/thousand_island/components/footer.rb', line 59
def numbering_options
options[:style].merge(options[:numbering_options])
end
|
#numbering_string ⇒ Object
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)
end
end
|
#repeated? ⇒ Boolean
63
64
65
|
# File 'lib/thousand_island/components/footer.rb', line 63
def repeated?
options[:repeated]
end
|