Class: YDocx::Parser
- Inherits:
-
Object
- Object
- YDocx::Parser
- Includes:
- MarkupMethod
- Defined in:
- lib/ydocx/parser.rb,
lib/ydocx/templates/patinfo.rb,
lib/ydocx/templates/fachinfo.rb
Constant Summary collapse
- @@figure_pattern =
/‘|’|'|´/
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#images ⇒ Object
Returns the value of attribute images.
-
#indecies ⇒ Object
Returns the value of attribute indecies.
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#result ⇒ Object
Returns the value of attribute result.
-
#space ⇒ Object
Returns the value of attribute space.
Instance Method Summary collapse
- #init ⇒ Object
-
#initialize(doc, rel) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Methods included from MarkupMethod
Constructor Details
#initialize(doc, rel) ⇒ Parser
Returns a new instance of Parser.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ydocx/parser.rb', line 12 def initialize(doc, rel) @doc = Nokogiri::XML.parse(doc) @rel = Nokogiri::XML.parse(rel) @coder = HTMLEntities.new @indecies = [] @images = [] @result = [] @space = ' ' @image_path = 'images' @image_style = '' init if block_given? yield self end end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
8 9 10 |
# File 'lib/ydocx/templates/fachinfo.rb', line 8 def code @code end |
#images ⇒ Object
Returns the value of attribute images.
11 12 13 |
# File 'lib/ydocx/parser.rb', line 11 def images @images end |
#indecies ⇒ Object
Returns the value of attribute indecies.
11 12 13 |
# File 'lib/ydocx/parser.rb', line 11 def indecies @indecies end |
#lang ⇒ Object
Returns the value of attribute lang.
8 9 10 |
# File 'lib/ydocx/templates/fachinfo.rb', line 8 def lang @lang end |
#result ⇒ Object
Returns the value of attribute result.
11 12 13 |
# File 'lib/ydocx/parser.rb', line 11 def result @result end |
#space ⇒ Object
Returns the value of attribute space.
11 12 13 |
# File 'lib/ydocx/parser.rb', line 11 def space @space end |
Instance Method Details
#init ⇒ Object
27 28 |
# File 'lib/ydocx/parser.rb', line 27 def init end |
#parse ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ydocx/parser.rb', line 29 def parse @doc.xpath('//w:document//w:body').children.map do |node| case node.node_name when 'text' @result << parse_paragraph(node) when 'tbl' @result << parse_table(node) when 'p' @result << parse_paragraph(node) else # skip end end @result end |