class OoxmlParser::ParagraphRun

Class for parsing `r` tags

Attributes

properties[RW]
t[R]

@return [Text] text of run

tab[R]

@return [Tab] tab of paragraph

text[RW]

Public Class Methods

new(properties = RunProperties.new, text = '', parent: nil) click to toggle source
Calls superclass method OoxmlParser::OOXMLDocumentObject::new
# 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

Public Instance Methods

empty?() click to toggle source

@return [True, False] is current run empty

# File lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb, line 39
def empty?
  text.empty?
end
instruction() click to toggle source

@return [String] instruction applied to paragraph

# File lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb, line 44
def instruction
  parent.instruction
end
page_number() click to toggle source

@return [True, False] is page number applyed

# File lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb, line 49
def page_number
  parent.page_numbering?
end
parse(node) click to toggle source

Parse ParagraphRun object @param node [Nokogiri::XML:Element] node to parse @return [ParagraphRun] result of parsing

# 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