Class: TableHelper::Footer
- Inherits:
-
HtmlElement
- Object
- HtmlElement
- TableHelper::Footer
- Defined in:
- lib/table_helper/footer.rb
Overview
Represents the header of the table. In HTML, you can think of this as the <tfoot> tag of the table.
Instance Attribute Summary collapse
-
#hide_when_empty ⇒ Object
Whether or not the footer should be hidden when the collection is empty.
-
#row ⇒ Object
readonly
The actual footer row.
-
#table ⇒ Object
readonly
The table this footer is a part of.
Instance Method Summary collapse
-
#html ⇒ Object
:nodoc:.
-
#initialize(table) ⇒ Footer
constructor
:nodoc:.
Constructor Details
Instance Attribute Details
#hide_when_empty ⇒ Object
Whether or not the footer should be hidden when the collection is empty. Default is true.
15 16 17 |
# File 'lib/table_helper/footer.rb', line 15 def hide_when_empty @hide_when_empty end |
#row ⇒ Object (readonly)
The actual footer row
11 12 13 |
# File 'lib/table_helper/footer.rb', line 11 def row @row end |
#table ⇒ Object (readonly)
The table this footer is a part of
8 9 10 |
# File 'lib/table_helper/footer.rb', line 8 def table @table end |
Instance Method Details
#html ⇒ Object
:nodoc:
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/table_helper/footer.rb', line 27 def html #:nodoc: # Force the last cell to span the remaining columns cells = row.cells.values colspan = table.header.columns.length - cells[0..-2].inject(0) {|count, cell| count += (cell[:colspan] || 1).to_i} cells.last[:colspan] ||= colspan if colspan > 1 = @html_options.dup [:style] = "display: none; #{[:style]}".strip if table.empty? && hide_when_empty content_tag(tag_name, content, ) end |