Class: Fog::Parsers::Terremark::Shared::GetKeysList
- Inherits:
-
Base
- Object
- Nokogiri::XML::SAX::Document
- Base
- Fog::Parsers::Terremark::Shared::GetKeysList
show all
- Defined in:
- lib/fog/terremark/parsers/shared/get_keys_list.rb
Instance Attribute Summary
Attributes inherited from Base
#response
Instance Method Summary
collapse
Methods inherited from Base
#attr_value, #characters, #initialize, #value
Instance Method Details
#end_element(name) ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'lib/fog/terremark/parsers/shared/get_keys_list.rb', line 41
def end_element(name)
case name
when 'Id', 'Href', 'Name', 'IsDefault','FingerPrint'
@key[name] = value
when 'Key'
@response['Keys'] << @key
@key = {}
end
end
|
#reset ⇒ Object
9
10
11
12
|
# File 'lib/fog/terremark/parsers/shared/get_keys_list.rb', line 9
def reset
@response = { 'Keys' => [] }
@key = {}
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
38
39
|
# File 'lib/fog/terremark/parsers/shared/get_keys_list.rb', line 14
def start_element(name, attributes)
super
case name
when 'Id', 'Href', 'Name', 'IsDefault','FingerPrint'
data = {}
until attributes.empty?
data[attributes.shift] = attributes.shift
end
@key[name] = data
when 'Key'
until attributes.empty?
@key[attributes.shift] = attributes.shift
end
when 'Keys'
keys_list = {}
until attributes.empty?
if attributes.first.is_a?(Array)
attribute = attributes.shift
keys_list[attribute.first] = attribute.last
else
keys_list[attributes.shift] = attributes.shift
end
end
@response['href'] = keys_list['href']
end
end
|