Module: EdifactConverter::ConverterMethods
- Included in:
- Result
- Defined in:
- lib/edifact_converter/converter_methods.rb
Instance Method Summary collapse
Instance Method Details
#binary(id) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/edifact_converter/converter_methods.rb', line 38 def binary(id) if xml xml2 = Nokogiri::XML xml.to_s xml2.remove_namespaces! binary_object = xml2.root.at("//BinaryObject[ObjectIdentifier = '#{id}']") Binary.from_element binary_object if binary_object end end |
#convert ⇒ Object
7 8 9 10 11 |
# File 'lib/edifact_converter/converter_methods.rb', line 7 def convert self.ast = build_ast if ast.nil? self.edifact = build_edifact if edifact.nil? self.xml = build_xml if xml.nil? end |
#format_edifact ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/edifact_converter/converter_methods.rb', line 13 def format_edifact if edifact formatted = edifact.encode 'utf-8' formatted.gsub! /[\n\r]/, "" formatted.gsub! /([^?]{1}')/, "\\1\n" formatted.gsub! /^\s*/, "" formatted.encode 'iso8859-1' else build_edifact(true) end end |
#html ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/edifact_converter/converter_methods.rb', line 25 def html if xml && xml.root && xml.root.namespace rules = Configuration.xml_rules xml.root.namespace.href if rules rules.to_html.transform xml else "<html><head><title>Fejl</title></head><body><h1>Ukendt namespace</h1><b>#{xml.root.namespace}</b></body></html>" end else "<html><head><title>Fejl</title></head><body><h1>Ingen xml tilgængelig</h1></body></html>" end end |
#verify ⇒ Object
47 48 49 |
# File 'lib/edifact_converter/converter_methods.rb', line 47 def verify compare_xml11 end |