Class: Foundry::Parsers::XML
- Inherits:
-
Object
- Object
- Foundry::Parsers::XML
- Defined in:
- lib/foundry/parsers/xml.rb
Instance Method Summary collapse
Instance Method Details
#parse(str) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/foundry/parsers/xml.rb', line 7 def parse(str) raise TypeError if str.nil? root_node = REXML::Document.new(str).first raise ArgumentError unless root_node.name == 'config' result = {} root_node.children.each { |node| result[node.name] = node.text } inherit = root_node.attributes['inherit'] result['inherit'] = inherit unless inherit.nil? result end |