Class: Fog::Parsers::Compute::AWS::DescribeInstanceStatus

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/aws/parsers/compute/describe_instance_status.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

#end_element(name) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/fog/aws/parsers/compute/describe_instance_status.rb', line 40

def end_element(name)
  case name
  #Simple closers
  when 'instanceId', 'availabilityZone'
    @instance[name] = value
  when 'nextToken', 'requestId'
    @response[name] = value
  when 'systemStatus', 'instanceState', 'instanceStatus', 'eventsSet'
    @inside = nil
  when 'item'
    case @inside
    when :eventsSet
      @instance['eventsSet'] << @item
    when :systemStatus, :instanceStatus
      @instance[@inside.to_s]['details'] << @item
    when nil
      @response['instanceStatusSet'] << @instance
    end
    @item = nil
  when 'code'
    case @inside
    when :eventsSet
      @item[name] = value
    when :instanceState
      @instance[@inside.to_s][name] = value.to_i
    end
  when 'description', 'notBefore', 'notAfter', 'name', 'status'
    @item.nil? ? (@instance[@inside.to_s][name] = value) : (@item[name] = value)
  end
end

#new_instance!Object



7
8
9
# File 'lib/fog/aws/parsers/compute/describe_instance_status.rb', line 7

def new_instance!
  @instance = { 'instanceState' => {}, 'systemStatus' => { 'details' => [] }, 'instanceStatus' => { 'details' => [] }, 'eventsSet' => [] }
end

#new_item!Object



11
12
13
# File 'lib/fog/aws/parsers/compute/describe_instance_status.rb', line 11

def new_item!
  @item = {}
end

#resetObject



15
16
17
18
# File 'lib/fog/aws/parsers/compute/describe_instance_status.rb', line 15

def reset
  @response = { 'instanceStatusSet' => [] }
  @inside = nil
end

#start_element(name, attrs = []) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/aws/parsers/compute/describe_instance_status.rb', line 20

def start_element(name, attrs=[])
  super
  case name
  when 'item'
    if @inside
      new_item!
    else
      new_instance!
    end
  when 'systemStatus'
    @inside = :systemStatus
  when 'instanceState'
    @inside = :instanceState
  when 'instanceStatus'
    @inside = :instanceStatus
  when 'eventsSet'
    @inside = :eventsSet
  end
end