Class: Docx::Elements::Containers::Table
- Inherits:
-
Object
- Object
- Docx::Elements::Containers::Table
- Defined in:
- lib/docx/containers/table.rb
Constant Summary
Constants included from Element
Instance Attribute Summary
Attributes included from Element
Class Method Summary collapse
Instance Method Summary collapse
- #column_count ⇒ Object
-
#columns ⇒ Object
Array of column.
-
#each_rows ⇒ Object
Iterate over each row within a table.
-
#initialize(node) ⇒ Table
constructor
A new instance of Table.
- #row_count ⇒ Object
-
#rows ⇒ Object
Array of row.
Methods included from Element
#append_to, #copy, #html_tag, included, #insert_after, #insert_before, #parent, #parent_paragraph, #prepend_to
Methods included from Container
#blank!, #properties, #remove!
Constructor Details
#initialize(node) ⇒ Table
Returns a new instance of Table.
16 17 18 19 |
# File 'lib/docx/containers/table.rb', line 16 def initialize(node) @node = node @properties_tag = 'tblGrid' end |
Class Method Details
.tag ⇒ Object
12 13 14 |
# File 'lib/docx/containers/table.rb', line 12 def self.tag 'tbl' end |
Instance Method Details
#column_count ⇒ Object
39 40 41 |
# File 'lib/docx/containers/table.rb', line 39 def column_count @node.xpath('w:tblGrid/w:gridCol').count end |
#columns ⇒ Object
Array of column
31 32 33 34 35 36 37 |
# File 'lib/docx/containers/table.rb', line 31 def columns columns_containers = [] (0..(column_count-1)).each do |i| columns_containers[i] = Containers::TableColumn.new @node.xpath("w:tr//w:tc[#{i+1}]") end columns_containers end |
#each_rows ⇒ Object
Iterate over each row within a table
44 45 46 |
# File 'lib/docx/containers/table.rb', line 44 def each_rows rows.each { |r| yield(r) } end |
#row_count ⇒ Object
26 27 28 |
# File 'lib/docx/containers/table.rb', line 26 def row_count @node.xpath('w:tr').count end |
#rows ⇒ Object
Array of row
22 23 24 |
# File 'lib/docx/containers/table.rb', line 22 def rows @node.xpath('w:tr').map {|r_node| Containers::TableRow.new(r_node) } end |