Class: MsDocx::Paragraph
- Inherits:
-
Object
- Object
- MsDocx::Paragraph
- Defined in:
- lib/ms_docx/paragraph.rb
Overview
Instance Method Summary collapse
-
#initialize(xml_element) ⇒ Paragraph
constructor
Nokogiri::XML::Element.
- #text ⇒ Object
- #text=(value) ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(xml_element) ⇒ Paragraph
Nokogiri::XML::Element
6 7 8 |
# File 'lib/ms_docx/paragraph.rb', line 6 def initialize(xml_element) @xml_element = xml_element end |
Instance Method Details
#text ⇒ Object
14 15 16 |
# File 'lib/ms_docx/paragraph.rb', line 14 def text @xml_element.xpath(@xml_element.path + '//w:r//w:t').map(&:content).join('') end |
#text=(value) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/ms_docx/paragraph.rb', line 19 def text=(value) text_node = @xml_element.xpath(@xml_element.path + '//w:r//w:t').first text_node.content = value if text_node end |
#to_xml ⇒ Object
10 11 12 |
# File 'lib/ms_docx/paragraph.rb', line 10 def to_xml @xml_element.to_xml end |