Class: Fog::Parsers::Terremark::Shared::GetCatalog

Inherits:
TerremarkParser show all
Defined in:
lib/fog/terremark/parsers/shared/get_catalog.rb

Instance Method Summary collapse

Methods inherited from TerremarkParser

#extract_attributes

Instance Method Details

#end_element(name) ⇒ Object



24
25
26
27
28
# File 'lib/fog/terremark/parsers/shared/get_catalog.rb', line 24

def end_element(name)
  if name == 'Description'
    @response[name] = value
  end
end

#resetObject



6
7
8
# File 'lib/fog/terremark/parsers/shared/get_catalog.rb', line 6

def reset
  @response = { 'CatalogItems' => [] }
end

#start_element(name, attributes) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fog/terremark/parsers/shared/get_catalog.rb', line 10

def start_element(name, attributes)
  super
  case name
  when 'CatalogItem'
    catalog_item = extract_attributes(attributes)
    catalog_item["id"] = catalog_item["href"].split('/').last
    @response['CatalogItems'] << catalog_item

  when 'Catalog'
    catalog = extract_attributes(attributes)
    @response['name'] = catalog['name']
  end
end