Class: Docx::Elements::Containers::TableCell

Inherits:
Object
  • Object
show all
Includes:
Container, Element
Defined in:
lib/docx/containers/table_cell.rb

Constant Summary

Constants included from Element

Element::DEFAULT_TAG

Instance Attribute Summary

Attributes included from Element

#node

Class Method Summary collapse

Instance Method Summary collapse

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) ⇒ TableCell

Returns a new instance of TableCell.



15
16
17
18
# File 'lib/docx/containers/table_cell.rb', line 15

def initialize(node)
  @node = node
  @properties_tag = 'tcPr'
end

Class Method Details

.tagObject



11
12
13
# File 'lib/docx/containers/table_cell.rb', line 11

def self.tag
  'tc'
end

Instance Method Details

#each_paragraphObject

Iterate over each text run within a paragraph’s cell



31
32
33
# File 'lib/docx/containers/table_cell.rb', line 31

def each_paragraph
  paragraphs.each { |tr| yield(tr) }
end

#paragraphsObject

Array of paragraphs contained within cell



26
27
28
# File 'lib/docx/containers/table_cell.rb', line 26

def paragraphs
  @node.xpath('w:p').map {|p_node| Containers::Paragraph.new(p_node) }
end

#to_sObject Also known as: text

Return text of paragraph’s cell



21
22
23
# File 'lib/docx/containers/table_cell.rb', line 21

def to_s
  paragraphs.map(&:text).join('')
end