Class: Awsum::Ec2::AddressParser
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(ec2) ⇒ AddressParser
constructor
A new instance of AddressParser.
- #result ⇒ Object
- #tag_end(tag) ⇒ Object
- #tag_start(tag, attributes) ⇒ Object
- #text(text) ⇒ Object
Methods inherited from Parser
Constructor Details
#initialize(ec2) ⇒ AddressParser
Returns a new instance of AddressParser.
61 62 63 64 65 66 |
# File 'lib/ec2/address.rb', line 61 def initialize(ec2) @ec2 = ec2 @addresses = [] @text = nil @stack = [] end |
Instance Method Details
#result ⇒ Object
113 114 115 |
# File 'lib/ec2/address.rb', line 113 def result @addresses end |
#tag_end(tag) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/ec2/address.rb', line 90 def tag_end(tag) case tag when 'DescribeAddressesResponse' #no-op when 'addressesSet' @stack.pop when 'item', 'AllocateAddressResponse' case @stack[-1] when 'addressesSet' @addresses << Address.new( @ec2, @current['publicIp'], @current['instanceId'] ) end else unless @text.nil? || @current.nil? text = @text.strip @current[tag] = (text == '' ? nil : text) end end end |
#tag_start(tag, attributes) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/ec2/address.rb', line 68 def tag_start(tag, attributes) #Quick hack so we can use the same parser for AllocateAddress which doesn't use the item tag to wrap the address information if tag == 'AllocateAddressResponse' @stack << 'addressesSet' end case tag when 'addressesSet' @stack << 'addressesSet' when 'item', 'AllocateAddressResponse' case @stack[-1] when 'addressesSet' @current = {} end end @text = '' end |
#text(text) ⇒ Object
86 87 88 |
# File 'lib/ec2/address.rb', line 86 def text(text) @text << text unless @text.nil? end |