Class: OoxmlParser::ParagraphRun

Inherits:
OOXMLDocumentObject show all
Extended by:
Gem::Deprecate
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

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

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

Returns a new instance of ParagraphRun.



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

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

Instance Attribute Details

#propertiesObject

Returns the value of attribute properties.



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

def properties
  @properties
end

#tText (readonly)

Returns text of run.

Returns:

  • (Text)

    text of run



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

def t
  @t
end

#tabTab (readonly)

Returns tab of paragraph.

Returns:

  • (Tab)

    tab of paragraph



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

def tab
  @tab
end

#textObject

Returns the value of attribute text.



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

def text
  @text
end

Instance Method Details

#empty?True, False

Returns is current run empty.

Returns:

  • (True, False)

    is current run empty



39
40
41
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb', line 39

def empty?
  text.empty?
end

#instructionString

Returns instruction applied to paragraph.

Returns:

  • (String)

    instruction applied to paragraph



44
45
46
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb', line 44

def instruction
  parent.instruction
end

Returns link of run.

Returns:



54
55
56
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb', line 54

def link
  parent.parent.hyperlink
end

#page_numberTrue, False

Returns is page number applyed.

Returns:

  • (True, False)

    is page number applyed



49
50
51
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb', line 49

def page_number
  parent.page_numbering?
end

#parse(node) ⇒ ParagraphRun

Parse ParagraphRun object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



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

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