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
-
#chapters ⇒ Object
Fachinfo Chapters 1.
- #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.
11 12 13 |
# File 'lib/ydocx/parser.rb', line 11 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
#chapters ⇒ Object
Fachinfo Chapters
1. name
2. composition
3. galenic form
4. indications
5. usage
6. contra_indications
7. restrictions
8. interactions
9. pregnancy
-
driving_ability
-
unwanted_effects
-
overdose
-
effects
-
kinetic
-
preclinic
-
other_advice
-
iksnr
-
packages
-
registration_owner
-
date
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ydocx/templates/fachinfo.rb', line 37 def chapters # TODO # Franzoesisch chapters = { 'Information' => /^Information\s+für\sPatientinnen\s+und\s+Patienten$/u, # 1 'Name' => /^Name\s+des\s+Präparates$/u, # 2 'Eigensch.' => /^Was\s+ist\s+\w+\s+und\s+wann\s+wird\s+es\s+angewendet\s*\??$/u, # 3 'Abänderung' => /^Was\s+sollte\s+dazu\s+beachtet\s+werden\s*\??$/u, # 4 'Kontraind.' => /^Wann\s+darf\s+\w+\s+nicht\s+(eingenommen\s*\/\s*angewendet|eingenommen|angewendet)\s*werden\s*\??$/u, # 5 'Vorbeugung' => /^Wann\s+ist\s+bei\s+der\s+(Einnahme\s*\/\s*Anwendung|Einnahme|Anwendung)\s*von\s+\w+\s+Vorsicht\s+geboten\s*\??$/u, # 6 'Schwanderschaft' => /^Darf\s+\w+\s+während\s+einer\s+Schwangerschaft\s+oder\s+in\s+der\s+Stillzeit\s+(eingenommen\s*\/\s*angewendet|eingenommen|angewendet)\s*werden\s*\??$/u, # 7 'Dos./Anw.' => /^Wie\s+verwenden\s+Sie\s+\w+\s*\??$/u, # 8 'Unerw.Wirkungen' => /^Welche\s+Nebenwirkungen\s+kann\s+\w+\s+haben\s*\??$/u, # 9 'Gewöhnliche H.' => /^Was\s+ist\s+ferner\s+zu\s+beachten\s*\??$/u, # 10 'Zusammens.' => /^Was\s+ist\s+in\s+\w+\s+enthalten\s*\??$/u, # 11 'Swissmedic-Nr.' => /^Zulassungsnummer$/u, # 12 'Packungen' => /^Wo\s+erhalten\s+Sie\s+\w+\s*\?\s*Welche\s+Packungen\s+sind\s+erhältlich\s*\??$/u, # 13 'Verteiler' => /^Zulassungsinhaberin$/u, # 14 'Hersteller' => /^Herstellerin$/u, # 15 'Stand d. Info.' => /^Diese\sPackungsbeilage\s+wurde\s+im\s+[\.A-z\s0-9]+(\s+|\s*\/\s*\w+\s+\(Monat\s*\/\s*Jahr\)\s*)letztmals\s+durch\s+die\s+Arzneimittelbehörde\s*\(\s*Swissmedic\s*\)\s*geprüft.?$/u, # 16 } end |
#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 |