Class: Fog::Parsers::Vcloud::Terremark::Ecloud::GetInternetServices

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

Instance Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from Base

#characters, #initialize

Constructor Details

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

Instance Method Details

#end_element(name) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/vcloud/terremark/ecloud/parsers/get_internet_services.rb', line 27

def end_element(name)
  target = case @in
  when :service
    @service
  when :public_ip
    @public_ip
  end

  case name
  when 'Href'
    target[name.downcase] = URI.parse(@value)
  when 'Name', 'Protocol', 'Description', 'SendString', 'HttpHeader'
    #The gsub takes the CamelCase names and turns them into camel_case
    target[Fog::Parsers::Vcloud.de_camel(name)] = @value
  when 'Id', 'Port', 'Timeout'
    target[name.downcase] = @value.to_i
  when 'Enabled'
    @service[name.downcase] = ( @value == "true" ? true : false )
  when 'InternetService'
    @response.links << @service
    @in = nil
  when 'PublicIpAddress'
    @service.public_ip = @public_ip
    @in = :service
  end
end

#resetObject



9
10
11
12
13
# File 'lib/fog/vcloud/terremark/ecloud/parsers/get_internet_services.rb', line 9

def reset
  @response = Struct::TmrkEcloudList.new([])
  @in = nil
  @public_ip = nil
end

#start_element(name, attributes) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/vcloud/terremark/ecloud/parsers/get_internet_services.rb', line 15

def start_element(name, attributes)
  @value = nil
  case name
  when 'InternetService'
    @in = :service
    @service = Struct::TmrkEcloudInternetService.new("application/vnd.tmrk.ecloud.internetService+xml")
  when 'PublicIpAddress'
    @in = :public_ip
    @public_ip = Struct::TmrkEcloudPublicIp.new("application/vnd.tmrk.ecloud.publicIp+xml")
  end
end