2010-04-16 03:20:02 -04:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
|
|
|
module Terremark
|
|
|
|
module Shared
|
|
|
|
|
|
|
|
class GetOrganization < Fog::Parsers::Base
|
|
|
|
|
|
|
|
def reset
|
|
|
|
@response = { 'Links' => [] }
|
|
|
|
end
|
|
|
|
|
|
|
|
def start_element(name, attributes)
|
2010-05-05 16:39:41 -04:00
|
|
|
super
|
2010-04-16 03:20:02 -04:00
|
|
|
case name
|
|
|
|
when 'Link'
|
|
|
|
link = {}
|
|
|
|
until attributes.empty?
|
2010-12-07 19:37:43 -05:00
|
|
|
if attributes.first.is_a?(Array)
|
|
|
|
attribute = attributes.shift
|
|
|
|
link[attribute.first] = attribute.last
|
|
|
|
else
|
|
|
|
link[attributes.shift] = attributes.shift
|
|
|
|
end
|
|
|
|
end
|
2010-04-16 03:20:02 -04:00
|
|
|
@response['Links'] << link
|
|
|
|
when 'Org'
|
|
|
|
org = {}
|
|
|
|
until attributes.empty?
|
|
|
|
if attributes.first.is_a?(Array)
|
|
|
|
attribute = attributes.shift
|
|
|
|
org[attribute.first] = attribute.last
|
|
|
|
else
|
|
|
|
org[attributes.shift] = attributes.shift
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@response['href'] = org['href']
|
|
|
|
@response['name'] = org['name']
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_element(name)
|
|
|
|
if name == 'Description'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = value
|
2010-04-16 03:20:02 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|