Class: RubyDocx::Elements::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_docx/elements.rb

Constant Summary collapse

ELEMENTS_ALIAS =
{
  "pPr" => RubyDocx::Elements::Style,
  "rPr" => RubyDocx::Elements::Style,
  "tblPr" => RubyDocx::Elements::TableStyle,
  "tcPr" => RubyDocx::Elements::TableStyle,
  "pict" => RubyDocx::Elements::Image,
  "drawing" => RubyDocx::Elements::Drawing,
  "p" => RubyDocx::Elements::Paragraph,
  "r" => RubyDocx::Elements::TextRun,
  "t" => RubyDocx::Elements::Text,
  "hyperlink" => RubyDocx::Elements::Link,
  "bookmarkStart" => RubyDocx::Elements::Bookmark,
  "tbl" => RubyDocx::Elements::Table,
  "tr" => RubyDocx::Elements::TableRow,
  "tc" => RubyDocx::Elements::TableCell,
  "tblGrid" => RubyDocx::Elements::TableColumn,
  "object" => RubyDocx::Elements::OleObject,
  # "bookmarkEnd" => RubyDocx::Elements::Link,
  "br" => RubyDocx::Elements::BreakLine,
  "oMathPara" => RubyDocx::Elements::Equation,
}

Class Method Summary collapse

Class Method Details

.parse_by_name(doc, c_node) ⇒ Object



45
46
47
48
49
50
# File 'lib/ruby_docx/elements.rb', line 45

def self.parse_by_name(doc, c_node)
  if ELEMENTS_ALIAS.keys.index(c_node.name.to_s)
    ELEMENTS_ALIAS[c_node.name.to_s].new(doc, c_node)
  end

end