Class: Fog::Parsers::Vcloud::Terremark::Ecloud::InternetService

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/vcloud/terremark/ecloud/parsers/internet_service.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



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

def end_element(name)
  target = case @in
  when :service
    @response
  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'
    @response[name.downcase] = ( @value == "true" ? true : false )
  when 'InternetService'
    @in = nil
  when 'PublicIpAddress'
    @response.public_ip = @public_ip
    @in = :service
  end
end

#resetObject



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

def reset
  @response = Struct::TmrkEcloudInternetService.new("application/vnd.tmrk.ecloud.internetService+xml")
  @in = nil
  @public_ip = nil
end

#start_element(name, attributes) ⇒ Object



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

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