Class: Tablette::Table
Instance Attribute Summary
Attributes inherited from Element
Instance Method Summary collapse
- #footer(&block) ⇒ Object
- #header(&block) ⇒ Object
-
#initialize(*args, &block) ⇒ Table
constructor
A new instance of Table.
- #to_html(*args) ⇒ Object
Methods inherited from Element
#element_to_html, #method_missing, #respond_to_missing?
Constructor Details
#initialize(*args, &block) ⇒ Table
Returns a new instance of Table.
14 15 16 17 18 19 |
# File 'lib/tablette/table.rb', line 14 def initialize(*args, &block) @renderer = HTMLRenderer.new @helper = nil super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Tablette::Element
Instance Method Details
#footer(&block) ⇒ Object
27 28 29 30 31 |
# File 'lib/tablette/table.rb', line 27 def (&block) do column(html_options: { colspan: 'auto'}, &block) end end |
#header(&block) ⇒ Object
21 22 23 24 25 |
# File 'lib/tablette/table.rb', line 21 def header(&block) header! do column(html_options: { colspan: 'auto'}, &block) end end |
#to_html(*args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/tablette/table.rb', line 33 def to_html(*args) columns = 0 all_sections = [ self.header!, self.body, self. ].flatten all_sections.each do |section| section_columns = section.columns_for_section args columns = section_columns if section_columns > columns end all_sections.each do |section| section.update_auto_colspan! columns, args end @renderer.to_html(super) end |