Class: ObjectView::Table
- Defined in:
- lib/object_view/table.rb
Instance Attribute Summary collapse
-
#tbody ⇒ Object
readonly
Returns the value of attribute tbody.
-
#thead ⇒ Object
readonly
Returns the value of attribute thead.
Attributes inherited from Element
#acceptable_children, #children, #single_line, #tag
Instance Method Summary collapse
- #header_row(labels = nil) ⇒ Object
-
#initialize ⇒ Table
constructor
A new instance of Table.
- #row(cell_data = nil, cell_attributes = nil) ⇒ Object
Methods inherited from Element
#<<, #add, #add_with_tag, #attr, #attributes, #css_class=, #find_element_with_tag, #id=, #is_acceptable_child?, #on_click=, #render, #render_attributes, #render_children, #style, #style=
Constructor Details
Instance Attribute Details
#tbody ⇒ Object (readonly)
Returns the value of attribute tbody.
6 7 8 |
# File 'lib/object_view/table.rb', line 6 def tbody @tbody end |
#thead ⇒ Object (readonly)
Returns the value of attribute thead.
6 7 8 |
# File 'lib/object_view/table.rb', line 6 def thead @thead end |
Instance Method Details
#header_row(labels = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/object_view/table.rb', line 14 def header_row(labels = nil) self.add @thead = THead.new row = THeadRow.new @thead.add row if (labels != nil) labels.each do |label| row.cell(label) end end return row end |
#row(cell_data = nil, cell_attributes = nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/object_view/table.rb', line 26 def row(cell_data = nil, cell_attributes = nil) if (@tbody == nil) self.add @tbody = TBody.new end row = @tbody.row if (cell_data != nil) cell_data.each do |element| cell = row.cell(element) if (cell_attributes != nil) cell_attributes.each do |name, value| cell.attr(name.to_s, value) end end end end return row end |