Class: Awsum::Ec2::KeyPairParser
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(ec2) ⇒ KeyPairParser
constructor
A new instance of KeyPairParser.
- #result ⇒ Object
- #tag_end(tag) ⇒ Object
- #tag_start(tag, attributes) ⇒ Object
- #text(text) ⇒ Object
Methods inherited from Parser
Constructor Details
#initialize(ec2) ⇒ KeyPairParser
Returns a new instance of KeyPairParser.
15 16 17 18 19 20 |
# File 'lib/ec2/keypair.rb', line 15 def initialize(ec2) @ec2 = ec2 @key_pairs = [] @text = nil @stack = [] end |
Instance Method Details
#result ⇒ Object
70 71 72 |
# File 'lib/ec2/keypair.rb', line 70 def result @key_pairs end |
#tag_end(tag) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ec2/keypair.rb', line 44 def tag_end(tag) case tag when 'DescribeKeyPairsResponse' #no-op when 'keySet' @stack.pop when 'item', 'CreateKeyPairResponse' case @stack[-1] when 'keySet' @key_pairs << KeyPair.new( @ec2, @current['keyName'], @current['keyFingerprint'], @current['keyMaterial'] ) @text = '' end else unless @text.nil? text = @text.strip @current[tag] = (text == '' ? nil : text) @text = '' end end end |
#tag_start(tag, attributes) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ec2/keypair.rb', line 22 def tag_start(tag, attributes) #Quick hack so we can use the same parser for CreateKeyPair which doesn't use the item tag to wrap the key pair information if tag == 'CreateKeyPairResponse' @stack << 'keySet' end case tag when 'keySet' @stack << 'keySet' when 'item', 'CreateKeyPairResponse' case @stack[-1] when 'keySet' @current = {} @text = '' end end end |
#text(text) ⇒ Object
40 41 42 |
# File 'lib/ec2/keypair.rb', line 40 def text(text) @text << text unless @text.nil? end |