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

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/parsers/terremark/get_catalog.rb

Instance Method Summary collapse

Methods inherited from Base

#extract_attributes

Instance Method Details

#end_element(name) ⇒ Object



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

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

#resetObject



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

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

#start_element(name, attributes) ⇒ Object



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

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