1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/parsers/ec2/describe_images.rb

50 lines
1.3 KiB
Ruby
Raw Normal View History

module Fog
module Parsers
module AWS
module EC2
class DescribeImages < Fog::Parsers::Base
def reset
2009-08-01 04:15:44 -04:00
@image = { 'productCodes' => [] }
@response = { 'imagesSet' => [] }
end
def start_element(name, attrs = [])
if name == 'productCodes'
@in_product_codes = true
end
@value = ''
end
def end_element(name)
case name
2009-08-01 04:15:44 -04:00
when 'architecture', 'imageId', 'imageLocation', 'imageOwnerId', 'imageState', 'imageType', 'kernelId', 'platform', 'ramdiskId'
@image[name] = @value
when 'isPublic'
if @value == 'true'
2009-08-01 04:15:44 -04:00
@image[name] = true
else
2009-08-01 04:15:44 -04:00
@image[name] = false
end
when 'item'
unless @in_product_codes
2009-08-01 04:15:44 -04:00
@response['imagesSet'] << @image
@image = { 'productCodes' => [] }
end
when 'productCode'
2009-08-01 04:15:44 -04:00
@image['productCodes'] << @value
when 'productCodes'
@in_product_codes = false
when 'requestId'
2009-08-01 04:15:44 -04:00
@response[name] = @value
end
end
end
end
end
end
end