Class: PDFGen::SmartTable
- Inherits:
-
Table
- Object
- BaseRegion
- Table
- PDFGen::SmartTable
- Defined in:
- lib/smart_table.rb
Defined Under Namespace
Classes: RowsContainer
Instance Attribute Summary collapse
-
#body_regions ⇒ Object
Returns the value of attribute body_regions.
-
#data_source ⇒ Object
Returns the value of attribute data_source.
-
#header_region ⇒ Object
Returns the value of attribute header_region.
Attributes inherited from Table
#repeat_footer_on_each_page, #repeat_header_on_each_page
Attributes inherited from BaseRegion
Attributes included from BaseAttributes
#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
- #body(style = nil, &initialization_block) ⇒ Object
- #build_body ⇒ Object
- #build_header ⇒ Object
- #calculate_minimal_height ⇒ Object
- #header(style = nil, &initialization_block) ⇒ Object
-
#initialize(parent) ⇒ SmartTable
constructor
A new instance of SmartTable.
- #regions_formation ⇒ Object
- #render(pos, av_height, test = false) ⇒ Object
Methods inherited from Table
#align_cell_in_row, #footer, #init_width, #title, #width=
Methods inherited from BaseRegion
#check_fit_in_height, #document, #minimal_height, #set_properties, #value
Methods included from BaseAttributes
#av_width, #border=, #border_params, #breakable?, included, #paddings=, #var_init
Methods included from BaseAttributes::ClassMethods
Constructor Details
#initialize(parent) ⇒ SmartTable
Returns a new instance of SmartTable.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/smart_table.rb', line 55 def initialize(parent) super(parent) @title = RowsContainer.new(self) @header = RowsContainer.new(self) @body = RowsContainer.new(self) @footer = RowsContainer.new(self) init_width(parent) @data_source = nil @header_data = nil @body_data = nil @is_header_rendered = false @is_body_rendered = false @columns = nil @body_regions = [] end |
Instance Attribute Details
#body_regions ⇒ Object
Returns the value of attribute body_regions.
11 12 13 |
# File 'lib/smart_table.rb', line 11 def body_regions @body_regions end |
#data_source ⇒ Object
Returns the value of attribute data_source.
86 87 88 |
# File 'lib/smart_table.rb', line 86 def data_source @data_source end |
#header_region ⇒ Object
Returns the value of attribute header_region.
11 12 13 |
# File 'lib/smart_table.rb', line 11 def header_region @header_region end |
Instance Method Details
#body(style = nil, &initialization_block) ⇒ Object
148 149 150 151 |
# File 'lib/smart_table.rb', line 148 def body(style = nil, &initialization_block) super @is_body_rendered = true end |
#build_body ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/smart_table.rb', line 125 def build_body() @body_data.each do |row| span = Span.new(self.document) span.width = self.width span.border = true row.each do |cap| = Caption.new(self.document) .text = cap .width = self.width / row.size .border_left = true yield(span, ) if block_given? span.add_region() end @body_regions << span end @is_body_rendered = true end |
#build_header ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/smart_table.rb', line 109 def build_header() span = Span.new(self.document) span.width = self.width span.border = true @header_data.each do |cap| = Caption.new(self.document) .text = cap .width = self.width / @header_data.size .border_left = true yield(span, ) if block_given? span.add_region() end @is_header_rendered = true span end |
#calculate_minimal_height ⇒ Object
88 89 90 91 |
# File 'lib/smart_table.rb', line 88 def calculate_minimal_height regions_formation super end |
#header(style = nil, &initialization_block) ⇒ Object
143 144 145 146 |
# File 'lib/smart_table.rb', line 143 def header(style = nil, &initialization_block) super @is_header_rendered = true end |
#regions_formation ⇒ Object
93 94 95 96 97 98 |
# File 'lib/smart_table.rb', line 93 def regions_formation @header.add_region(build_header) unless @is_header_rendered build_body unless @is_body_rendered @body_regions.each { |region| @body.add_region(region) } end |
#render(pos, av_height, test = false) ⇒ Object
100 101 102 103 104 105 106 107 |
# File 'lib/smart_table.rb', line 100 def render(pos, av_height, test=false) @header_region = nil if @is_header_rendered @body_regions.clear if @is_body_rendered regions_formation super end |