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/compute/describe_route_tables.rb
2013-08-16 10:51:38 -04:00

78 lines
2.3 KiB
Ruby
Executable file

module Fog
module Parsers
module Compute
module AWS
class DescribeRouteTables < Fog::Parsers::Base
def reset
@association = {}
@in_association_set = false
@in_route_set = false
@route = {}
@response = { 'routeTableSet' => [] }
@tag = {}
@route_table = { 'associationSet' => [], 'tagSet' => {}, 'routeSet' => [] }
end
def start_element(name, attrs = [])
super
case name
when 'associationSet'
@in_association_set = true
when 'tagSet'
@in_tag_set = true
when 'routeSet'
@in_route_set = true
end
end
def end_element(name)
if @in_association_set
case name
when 'associationSet'
@in_association_set = false
when 'routeTableAssociationId', 'routeTableId', 'subnetId', 'main'
@association[name] = value
when 'item'
@route_table['associationSet'] << @association
@association = {}
end
elsif @in_tag_set
case name
when 'key', 'value'
@tag[name] = value
when 'item'
@route_table['tagSet'][@tag['key']] = @tag['value']
@tag = {}
when 'tagSet'
@in_tag_set = false
end
elsif @in_route_set
case name
when 'destinationCidrBlock', 'gatewayId', 'state'
@route[name] = value
when 'item'
@route_table['routeSet'] << @route
when 'routeSet'
@in_route_set = false
end
else
case name
when 'routeTableId', 'vpcId'
@route_table[name] = value
when 'item'
@response['routeTableSet'] << @route_table
@route_table = { 'associationSet' => [], 'tagSet' => {}, 'routeSet' => [] }
when 'requestId'
@response[name] = value
end
end
end
end
end
end
end
end