class Foundry::Parsers::XML
Public Instance Methods
parse(str)
click to toggle source
# 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'] raise KeyError unless result['inherit'].nil? || inherit.nil? result['inherit'] = inherit unless inherit.nil? result end