Class: Swordfish::Node::Table
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#cell_at(row, col) ⇒ Object
Return the TableCell object at a given position.
-
#cols ⇒ Object
Get the number of columns in the table.
-
#rows ⇒ Object
Get the number of rows in the table.
- #to_html ⇒ Object
Methods inherited from Base
#append, #clear_children, #find_nodes_by_type, #inform!, #initialize, #replace, #replace_with, #stylize, #wrap_children
Constructor Details
This class inherits a constructor from Swordfish::Node::Base
Instance Method Details
#cell_at(row, col) ⇒ Object
Return the TableCell object at a given position
18 19 20 |
# File 'lib/swordfish/nodes/table.rb', line 18 def cell_at(row, col) @children[row].children[col] end |
#cols ⇒ Object
Get the number of columns in the table
13 14 15 |
# File 'lib/swordfish/nodes/table.rb', line 13 def cols @children[0].children.length end |
#rows ⇒ Object
Get the number of rows in the table
8 9 10 |
# File 'lib/swordfish/nodes/table.rb', line 8 def rows @children.length end |
#to_html ⇒ Object
22 23 24 25 |
# File 'lib/swordfish/nodes/table.rb', line 22 def to_html collapse_cells! "<table><tbody>#{@children.map(&:to_html).join}</tbody></table>" end |