Class: OoxmlParser::ParagraphRun

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb

Overview

Class for parsing ‘r` tags

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(properties = RunProperties.new, text = '', parent: nil) ⇒ ParagraphRun

Returns a new instance of ParagraphRun.



12
13
14
15
16
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb', line 12

def initialize(properties = RunProperties.new, text = '', parent: nil)
  @properties = properties
  @text = text
  @parent = parent
end

Instance Attribute Details

#propertiesObject

Returns the value of attribute properties.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb', line 6

def properties
  @properties
end

#tText (readonly)

Returns text of run.

Returns:

  • (Text)

    text of run



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb', line 8

def t
  @t
end

#tabTab (readonly)

Returns tab of paragraph.

Returns:

  • (Tab)

    tab of paragraph



10
11
12
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb', line 10

def tab
  @tab
end

#textObject

Returns the value of attribute text.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb', line 6

def text
  @text
end

Instance Method Details

#parse(node) ⇒ ParagraphRun

Parse ParagraphRun object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb', line 21

def parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'rPr'
      @properties = RunProperties.new(parent: self).parse(node_child)
    when 't'
      @t = Text.new(parent: self).parse(node_child)
      @text = t.text
    when 'tab'
      @tab = Tab.new(parent: self).parse(node_child)
    end
  end
  self
end