Class: Awsum::Ec2::KeyPairParser
- Defined in:
- lib/awsum/ec2/parsers/keypair_parser.rb
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.
4 5 6 7 8 9 |
# File 'lib/awsum/ec2/parsers/keypair_parser.rb', line 4 def initialize(ec2) @ec2 = ec2 @key_pairs = [] @text = nil @stack = [] end |
Instance Method Details
#result ⇒ Object
59 60 61 |
# File 'lib/awsum/ec2/parsers/keypair_parser.rb', line 59 def result @key_pairs end |
#tag_end(tag) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/awsum/ec2/parsers/keypair_parser.rb', line 33 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
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/awsum/ec2/parsers/keypair_parser.rb', line 11 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
29 30 31 |
# File 'lib/awsum/ec2/parsers/keypair_parser.rb', line 29 def text(text) @text << text unless @text.nil? end |