Class: MsDocx::Paragraph

Inherits:
Object
  • Object
show all
Defined in:
lib/ms_docx/paragraph.rb

Overview

Author:

  • Alex Mercury

Instance Method Summary collapse

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

#textObject



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_xmlObject



10
11
12
# File 'lib/ms_docx/paragraph.rb', line 10

def to_xml
  @xml_element.to_xml
end