Class: X12::XMLDefinitions
- Inherits:
-
Hash
- Object
- Hash
- X12::XMLDefinitions
- Defined in:
- lib/x12/xmldefinitions.rb
Overview
A class for parsing X12 message definition expressed in XML format.
Instance Method Summary collapse
-
#initialize(str) ⇒ XMLDefinitions
constructor
Parse definitions out of XML file.
Constructor Details
#initialize(str) ⇒ XMLDefinitions
Parse definitions out of XML file.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/x12/xmldefinitions.rb', line 7 def initialize(str) doc = LibXML::XML::Document.string(str) definitions = doc.root.name =~ /^Definition$/i ? doc.root.find('*').to_a : [doc.root] definitions.each do |element| # puts element.name syntax_element = case element.name when /table/i parse_table(element) when /segment/i parse_segment(element) when /composite/i parse_composite(element) when /loop/i parse_loop(element) end self[syntax_element.class] ||= {} self[syntax_element.class][syntax_element.name] = syntax_element end end |