Class: PDFGen::Table
Instance Attribute Summary collapse
Attributes inherited from BaseRegion
#parent
#background_color, #border_bottom, #border_color, #border_left, #border_right, #border_style, #border_top, #border_width, #height, #is_breakable, #pad_bottom, #pad_left, #pad_right, #pad_top, #page_pad_top, #width
Instance Method Summary
collapse
Methods inherited from BaseRegion
#check_fit_in_height, #document, #minimal_height, #set_properties, #value
#av_width, #border=, #border_params, #breakable?, included, #paddings=, #var_init
#common_setter
Constructor Details
#initialize(parent) ⇒ Table
Returns a new instance of Table.
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/table.rb', line 10
def initialize(parent)
super(parent)
@is_breakable = true
@title = Div.new(self)
@header = Div.new(self)
@body = Div.new(self)
@footer = Div.new(self)
init_width(parent)
@repeat_header_on_each_page = false
@repeat_footer_on_each_page = false
end
|
Instance Attribute Details
Returns the value of attribute repeat_footer_on_each_page.
36
37
38
|
# File 'lib/table.rb', line 36
def
@repeat_footer_on_each_page
end
|
Returns the value of attribute repeat_header_on_each_page.
36
37
38
|
# File 'lib/table.rb', line 36
def
@repeat_header_on_each_page
end
|
Instance Method Details
#align_cell_in_row ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/table.rb', line 38
def align_cell_in_row
[@header,@body,@footer].each do |container|
container.regions.each do |row|
row.vertical_align = true if row.respond_to?(:vertical_align)
end
end
end
|
#body(style = nil, &initialization_block) ⇒ Object
99
100
101
|
# File 'lib/table.rb', line 99
def body(style = nil, &initialization_block)
access_region(@body, style, &initialization_block)
end
|
#calculate_minimal_height ⇒ Object
46
47
48
|
# File 'lib/table.rb', line 46
def calculate_minimal_height
[@title,@header,@body,@footer].inject(0){ |height, region| height + region.height }
end
|
103
104
105
|
# File 'lib/table.rb', line 103
def (style = nil, &initialization_block)
access_region(@footer, style, &initialization_block)
end
|
95
96
97
|
# File 'lib/table.rb', line 95
def (style = nil, &initialization_block)
access_region(@header, style, &initialization_block)
end
|
#init_width(parent) ⇒ Object
24
25
26
|
# File 'lib/table.rb', line 24
def init_width(parent)
self.width = parent.width - parent.pad_left - parent.pad_right
end
|
#render(pos, av_height, test = false) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/table.rb', line 50
def render(pos, av_height, test=false)
align_cell_in_row
super
pos_x, pos_y = pos
title_height = @title.render([pos_x, pos_y], pos_y, true)
= @header.render([pos_x, pos_y], pos_y, true)
if (title_height[0] + [0]) > av_height
return [0, false]
end
title_status = @title.render([pos_x, pos_y], pos_y)
pos_y -= title_status[0]
@header.reset_count_rendered_regions if @repeat_header_on_each_page
= @header.render([pos_x, pos_y], pos_y)
pos_y -= [0]
status = @body.render([pos_x, pos_y], pos_y)
pos_y -= status[0]
= @footer.render([pos_x, pos_y], pos_y, true)
if [0] > pos[1]
return [av_height-pos_y, false]
end
if status[1]
= @footer.render([pos_x, pos_y], pos_y)
else
if @repeat_footer_on_each_page
= @footer.render([pos_x, pos_y], pos_y)
@footer.reset_count_rendered_regions
end
end
pos_y -= [0] if
[av_height-pos_y, status[1] && [1]]
end
|
#title(style = nil, &initialization_block) ⇒ Object
91
92
93
|
# File 'lib/table.rb', line 91
def title(style = nil, &initialization_block)
access_region(@title, style, &initialization_block)
end
|
#width=(value) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/table.rb', line 28
def width=(value)
[@title,@header,@body,@footer].each do |region|
region.width = value
end
super
end
|