Class: XParams

Inherits:
Object
  • Object
show all
Includes:
REXML
Defined in:
lib/xparams.rb

Class Method Summary collapse

Class Method Details

.parse(params = '<params/>') ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/xparams.rb', line 10

def self.parse(params='<params/>')

  doc = Document.new(params)

  if doc then
    h = XPath.match(doc.root, "param[@var]").inject({}) do |r, param|
      r.merge(param.attribute('var').to_s.to_sym => param.children.first.to_s)
    end
  end
  h || {}
end