Sha256: 81d458343d01651695a9d55bcb189e2966670876a36870016b336b7b21c22ab7
Contents?: true
Size: 1.42 KB
Versions: 5
Compression:
Stored size: 1.42 KB
Contents
module Awsum class Ec2 class AvailabilityZoneParser < Awsum::Parser #:nodoc: def initialize(ec2) @ec2 = ec2 @availability_zones = [] @text = nil @stack = [] end def tag_start(tag, attributes) case tag when 'availabilityZoneInfo' @stack << 'availabilityZoneInfo' when 'item' case @stack[-1] when 'availabilityZoneInfo' @current = {} end end @text = '' end def text(text) @text << text unless @text.nil? end def tag_end(tag) case tag when 'DescribeAvailabilityZonesResponse', 'requestId' #no-op when 'availabilityZoneInfo' @stack.pop when 'item' case @stack[-1] when 'availabilityZoneInfo' @availability_zones << AvailabilityZone.new( @ec2, @current['zoneName'], @current['zoneState'], @current['regionName'] ) end else unless @text.nil? || @current.nil? text = @text.strip @current[tag] = (text == '' ? nil : text) end end end def result @availability_zones end end end end
Version data entries
5 entries across 5 versions & 1 rubygems