Module: RAWS::XML

Defined in:
lib/raws/xml.rb,
lib/raws/xml/nokogiri.rb

Defined Under Namespace

Modules: Nokogiri

Class Method Summary collapse

Class Method Details

.unpack_attrs(attrs) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/raws/xml.rb', line 3

def self.unpack_attrs(attrs)
  ret = {}

  if attrs.is_a? Array
    attrs
  else
    [attrs]
  end.map do |val|
    name, value = val['Name'], val['Value']

    if ret.key? name
      ret[name] = [ret[name]] unless ret[name].is_a? Array
      ret[name] << value
    else
      ret[name] = value
    end
  end if attrs

  ret
end