Class: Fog::Parsers::Terremark::Shared::Network

Inherits:
TerremarkParser
  • Object
show all
Defined in:
lib/fog/terremark/parsers/shared/network.rb

Instance Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from TerremarkParser

#extract_attributes

Methods inherited from Base

#attr_value, #characters, #end_element_namespace, #initialize, #start_element_namespace, #value

Constructor Details

This class inherits a constructor from Fog::Parsers::Base

Instance Method Details

#end_element(name) ⇒ Object



31
32
33
34
35
36
# File 'lib/fog/terremark/parsers/shared/network.rb', line 31

def end_element(name)
  case name
  when "Gateway", "Netmask", "FenceMode"
    @response[name.downcase] = value
  end
end

#resetObject



8
9
10
11
12
# File 'lib/fog/terremark/parsers/shared/network.rb', line 8

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

#start_element(name, attributes = []) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/terremark/parsers/shared/network.rb', line 14

def start_element(name,attributes=[])
  super
  case name
  when "Network"
    @response = extract_attributes(attributes)
    if @response.has_key?("name")
      @response["subnet"] = @response["name"]
    end
    if @response.has_key?("href")
      @response["id"] = @response["href"].split("/").last
    end
  when "Link"
    link = extract_attributes(attributes)
    @response["links"] << link
  end
end