Class: Fog::Parsers::Compute::AWS::DescribeReservedInstances

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/aws/parsers/compute/describe_reserved_instances.rb

Instance Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary (collapse)

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

- (Object) end_element(name)



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
53
# File 'lib/fog/aws/parsers/compute/describe_reserved_instances.rb', line 27

def end_element(name)
  case name
  when 'availabilityZone', 'instanceType', 'productDescription', 'reservedInstancesId', 'state', 'offeringType'
    @reserved_instance[name] = value
  when 'duration', 'instanceCount'
    @reserved_instance[name] = value.to_i
  when 'fixedPrice', 'amount', 'usagePrice'
    @reserved_instance[name] = value.to_f
  when *@contexts
    @context.pop
  when 'item'
    case @context.last
    when 'reservedInstancesSet'
      @response['reservedInstancesSet'] << @reserved_instance
      @reserved_instance = get_default_item
    when 'tagSet'
      @reserved_instance['tagSet'][@tag['key']] = @tag['value']
      @tag = {}
    end
  when 'key', 'value'
    @tag[name] = value
  when 'requestId'
    @response[name] = value
  when 'start','end'
    @reserved_instance[name] = Time.parse(value)
  end
end

- (Object) get_default_item



6
7
8
# File 'lib/fog/aws/parsers/compute/describe_reserved_instances.rb', line 6

def get_default_item
  {'tagSet' => {}, 'recurringCharges' => {}}
end

- (Object) reset



10
11
12
13
14
15
16
17
18
# File 'lib/fog/aws/parsers/compute/describe_reserved_instances.rb', line 10

def reset
  @context = []
  # Note:  <recurringCharges> should also be handled as a set, but do not want to disrupt anyone relying on
  # it currently being flatted
  @contexts = ['reservedInstancesSet', 'tagSet']
  @reserved_instance = get_default_item
  @response = { 'reservedInstancesSet' => [] }
  @tag = {}
end

- (Object) start_element(name, attrs = [])



20
21
22
23
24
25
# File 'lib/fog/aws/parsers/compute/describe_reserved_instances.rb', line 20

def start_element(name, attrs = [])
  super
  if @contexts.include?(name)
    @context.push(name)
  end
end