Class: Docx::Elements::Containers::TableCell
- Inherits:
-
Object
- Object
- Docx::Elements::Containers::TableCell
- Defined in:
- lib/docx/containers/table_cell.rb
Constant Summary
Constants included from Element
Instance Attribute Summary
Attributes included from Element
Class Method Summary collapse
Instance Method Summary collapse
-
#each_paragraph ⇒ Object
Iterate over each text run within a paragraph’s cell.
-
#initialize(node) ⇒ TableCell
constructor
A new instance of TableCell.
-
#paragraphs ⇒ Object
Array of paragraphs contained within cell.
-
#to_s ⇒ Object
(also: #text)
Return text of paragraph’s cell.
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
.tag ⇒ Object
11 12 13 |
# File 'lib/docx/containers/table_cell.rb', line 11 def self.tag 'tc' end |
Instance Method Details
#each_paragraph ⇒ Object
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 |
#paragraphs ⇒ Object
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_s ⇒ Object 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 |