Class: Awsum::Ec2::RegionParser
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(ec2) ⇒ RegionParser
constructor
A new instance of RegionParser.
- #result ⇒ Object
- #tag_end(tag) ⇒ Object
- #tag_start(tag, attributes) ⇒ Object
- #text(text) ⇒ Object
Methods inherited from Parser
Constructor Details
#initialize(ec2) ⇒ RegionParser
Returns a new instance of RegionParser.
44 45 46 47 48 49 |
# File 'lib/ec2/region.rb', line 44 def initialize(ec2) @ec2 = ec2 @regions = [] @text = nil @stack = [] end |
Instance Method Details
#result ⇒ Object
91 92 93 |
# File 'lib/ec2/region.rb', line 91 def result @regions end |
#tag_end(tag) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/ec2/region.rb', line 68 def tag_end(tag) case tag when 'DescribeRegionsResponse', 'requestId' #no-op when 'regionInfo' @stack.pop when 'item' case @stack[-1] when 'regionInfo' @regions << Region.new( @ec2, @current['regionName'], @current['regionEndpoint'] ) end else unless @text.nil? || @current.nil? text = @text.strip @current[tag] = (text == '' ? nil : text) end end end |
#tag_start(tag, attributes) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ec2/region.rb', line 51 def tag_start(tag, attributes) case tag when 'regionInfo' @stack << 'regionInfo' when 'item' case @stack[-1] when 'regionInfo' @current = {} end end @text = '' end |
#text(text) ⇒ Object
64 65 66 |
# File 'lib/ec2/region.rb', line 64 def text(text) @text << text unless @text.nil? end |