Class: Swordfish::Node::Table

Inherits:
Base
  • Object
show all
Defined in:
lib/swordfish/nodes/table.rb

Instance Attribute Summary

Attributes inherited from Base

#children, #content, #style

Instance Method Summary collapse

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

#colsObject

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

#rowsObject

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_htmlObject



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