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

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

Instance Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from Base

#attr_value, #characters, #initialize, #value

Constructor Details

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

Instance Method Details

#end_element(name) ⇒ Object



39
40
41
42
43
44
# File 'lib/rackspace-fog/terremark/parsers/shared/network.rb', line 39

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

#resetObject



8
9
10
11
12
# File 'lib/rackspace-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
30
31
32
33
34
35
36
37
# File 'lib/rackspace-fog/terremark/parsers/shared/network.rb', line 14

def start_element(name,attributes=[])
  super
  case name
  when "Network"
    until attributes.empty?
      val = attributes.shift
      if val.is_a?(String)
        @response[val] = attributes.shift
      end
    end
    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 = {}
    until attributes.empty?
      link[attributes.shift] = attributes.shift
    end
    @response["links"] << link
  end
end