Class: OoxmlParser::DocxFormula
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::DocxFormula
- Defined in:
- lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb
Overview
Class for formula data
Instance Attribute Summary collapse
-
#argument_properties ⇒ ArgumentProperties
Properties of arguments.
-
#formula_run ⇒ Object
Returns the value of attribute formula_run.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#initialize(parent: nil) ⇒ DocxFormula
constructor
A new instance of DocxFormula.
-
#parse(node) ⇒ DocxFormula
Parse DocxFormula object.
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
Constructor Details
#initialize(parent: nil) ⇒ DocxFormula
23 24 25 26 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb', line 23 def initialize(parent: nil) @formula_run = [] @parent = parent end |
Instance Attribute Details
#argument_properties ⇒ ArgumentProperties
21 22 23 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb', line 21 def argument_properties @argument_properties end |
#formula_run ⇒ Object
Returns the value of attribute formula_run.
19 20 21 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb', line 19 def formula_run @formula_run end |
Instance Method Details
#parse(node) ⇒ DocxFormula
Parse DocxFormula object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb', line 31 def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'r' @formula_run << MathRun.new(parent: self).parse(node_child) when 'box', 'borderBox' @formula_run << Box.new(parent: self).parse(node_child) when 'func' @formula_run << Function.new(parent: self).parse(node_child) when 'rad' @formula_run << Radical.new(parent: self).parse(node_child) when 'e', 'eqArr' @formula_run << DocxFormula.new(parent: self).parse(node_child) when 'nary' @formula_run << Nary.new(parent: self).parse(node_child) when 'd' @formula_run << Delimiter.new(parent: self).parse(node_child) when 'sSubSup', 'sSup', 'sSub' @formula_run << Index.new(parent: self).parse(node_child) when 'f' @formula_run << Fraction.new(parent: self).parse(node_child) when 'm' @formula_run << Matrix.new(parent: self).parse(node_child) when 'bar' @formula_run << Bar.new(parent: self).parse(node_child) when 'acc' @formula_run << Accent.new(parent: self).parse(node_child) when 'groupChr' @formula_run << GroupChar.new(parent: self).parse(node_child) when 'argPr' @argument_properties = ArgumentProperties.new(parent: self).parse(node_child) when 'sPre' @formula_run << PreSubSuperscript.new(parent: self).parse(node_child) when 'limUpp', 'limLow' @formula_run << Limit.new(parent: self).parse(node_child) end end return nil if @formula_run.empty? self end |