Class: OoxmlParser::Paragraph

Inherits:
Object
  • Object
show all
Defined in:
lib/ooxml_parser/common_parser/common_data/paragraph.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runs = [], formulas = []) ⇒ Paragraph

Returns a new instance of Paragraph.



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

def initialize(runs = [], formulas = [])
  @runs = runs
  @formulas = formulas
  @runs = []
end

Instance Attribute Details

#formulasObject

Returns the value of attribute formulas.



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

def formulas
  @formulas
end

#propertiesObject

Returns the value of attribute properties.



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

def properties
  @properties
end

#runsObject Also known as: characters, character_style_array

Returns the value of attribute runs.



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

def runs
  @runs
end

#text_fieldObject

Returns the value of attribute text_field.



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

def text_field
  @text_field
end

Class Method Details

.parse(paragraph_node) ⇒ Object



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

def self.parse(paragraph_node)
  paragraph = Paragraph.new
  paragraph_node.xpath('*').each do |paragraph_node_child|
    case paragraph_node_child.name
    when 'pPr'
      paragraph.properties = ParagraphProperties.parse(paragraph_node_child)
    when 'fld'
      paragraph.text_field = TextField.parse(paragraph_node_child)
    when 'r'
      paragraph.characters << ParagraphRun.parse(paragraph_node_child)
    when 'm'
      # TODO: add parsing formulas in paragraph
    end
  end
  paragraph
end