Class: PrawnHtml::Tags::Table
Constant Summary
collapse
- ELEMENTS =
[:table].freeze
PrawnHtml::Tag::CALLBACKS, PrawnHtml::Tag::TAG_CLASSES
Instance Attribute Summary
#attrs, #parent, #tag
Instance Method Summary
collapse
#block_styles, class_for, #initialize, #process_styles, #tag_close_styles, #tag_open_styles
Constructor Details
This class inherits a constructor from PrawnHtml::Tag
Instance Method Details
#add_col_width(width) ⇒ Object
21
22
23
|
# File 'lib/prawn_html/tags/table.rb', line 21
def add_col_width(width)
@col_widths << width
end
|
#add_row(row_data) ⇒ Object
46
47
48
|
# File 'lib/prawn_html/tags/table.rb', line 46
def add_row(row_data)
@rows << row_data
end
|
#block? ⇒ Boolean
8
9
10
|
# File 'lib/prawn_html/tags/table.rb', line 8
def block?
true
end
|
#custom_render(pdf, _context) ⇒ Object
12
13
14
|
# File 'lib/prawn_html/tags/table.rb', line 12
def custom_render(pdf, _context)
@pdf_wrapper = pdf
end
|
#on_context_add(_context) ⇒ Object
16
17
18
19
|
# File 'lib/prawn_html/tags/table.rb', line 16
def on_context_add(_context)
@rows = []
@col_widths = []
end
|
#on_context_remove(_context) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/prawn_html/tags/table.rb', line 25
def on_context_remove(_context)
return if @pdf_wrapper.nil?
cell_style = {
borders: [:top, :bottom, :left, :right],
border_width: 1,
border_color: '000000',
padding: 5,
inline_format: true
}
if @col_widths.any?
@pdf_wrapper.table(@rows, column_widths: @col_widths, cell_style: cell_style)
else
@pdf_wrapper.table(@rows, cell_style: cell_style)
end
@rows = []
end
|