Class: Fog::Parsers::AWS::EC2::DescribeImages

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



25
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
51
52
53
# File 'lib/fog/aws/parsers/ec2/describe_images.rb', line 25

def end_element(name)
  case name
  when 'architecture',  'imageId', 'imageLocation', 'imageOwnerId', 'imageState', 'imageType', 'kernelId', 'platform', 'ramdiskId', 'rootDeviceType','rootDeviceName'
    @image[name] = @value
  when 'isPublic'
    if @value == 'true'
      @image[name] = true
    else
      @image[name] = false
    end
  when 'item'
    if @in_block_device_mapping
    elsif !@in_product_codes
      @response['imagesSet'] << @image
      @image = { 'productCodes' => [] }
    end
  when 'productCode'
    @image['productCodes'] << @value
  when 'productCodes'
    @in_product_codes = false
  when 'blockDeviceMapping'
    @in_block_device_mapping = false
  when 'requestId'
    @response[name] = @value
  when 'deviceName','virtualName','snapshotId','volumeSize','deleteOnTermination'
    l = @image['blockDeviceMapping'].length
    @image['blockDeviceMapping'][l-1].store(name,@value)
  end
end

#resetObject



8
9
10
11
# File 'lib/fog/aws/parsers/ec2/describe_images.rb', line 8

def reset
  @image = { 'productCodes' => [], 'blockDeviceMapping' => nil }
  @response = { 'imagesSet' => [] }
end

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



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/aws/parsers/ec2/describe_images.rb', line 13

def start_element(name, attrs = [])
  super
  if name == 'productCodes'
    @in_product_codes = true
  elsif name == 'blockDeviceMapping'
    @in_block_device_mapping = true
    @image['blockDeviceMapping'] = []
   elsif name == 'item' && @in_block_device_mapping
    @image['blockDeviceMapping'] << {}
  end
end