Class: RightAws::Ec2::QEc2DescribeSecurityGroupsParser

Inherits:
RightAWSParser show all
Defined in:
lib/ec2/right_ec2_security_groups.rb

Overview


PARSERS: Security Groups

Constant Summary

Constants inherited from RightAWSParser

RightAWSParser::DEFAULT_XML_LIBRARY

Instance Attribute Summary

Attributes inherited from RightAWSParser

#full_tag_name, #result, #tag, #xml_lib, #xmlpath

Instance Method Summary collapse

Methods inherited from RightAWSParser

#initialize, #method_missing, #parse, #tag_end, #tag_start, #tagtext, #text, xml_lib, xml_lib=

Constructor Details

This class inherits a constructor from RightAws::RightAWSParser

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RightAws::RightAWSParser

Instance Method Details

#resetObject



271
272
273
# File 'lib/ec2/right_ec2_security_groups.rb', line 271

def reset
  @result = []
end

#tagend(name) ⇒ Object



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/ec2/right_ec2_security_groups.rb', line 249

def tagend(name)
  case name
  when 'ownerId'          then @item[:owner_id]             = @text
  when 'groupDescription' then @item[:group_description]    = @text
  when 'ipProtocol'       then @ip_permission[:ip_protocol] = @text
  when 'fromPort'         then @ip_permission[:from_port]   = @text
  when 'toPort'           then @ip_permission[:to_port]     = @text
  when 'cidrIp'           then @ip_permission[:ip_ranges]  << @text
  when 'userId'           then @group[:user_id]             = @text
  when 'groupName'
    case
    when @xmlpath[/securityGroupInfo\/item$/] then @item[:group_name]  = @text
    when @xmlpath[/groups\/item$/]            then @group[:group_name] = @text
    end
  when 'item'
    case
    when @xmlpath[/groups$/]           then @ip_permission[:groups] << @group
    when @xmlpath[/ipPermissions$/]    then @item[:ip_permissions] << @ip_permission
    when @xmlpath[/securityGroupInfo$/]then @result << @item
    end
  end
end

#tagstart(name, attributes) ⇒ Object

:nodoc:



240
241
242
243
244
245
246
247
248
# File 'lib/ec2/right_ec2_security_groups.rb', line 240

def tagstart(name, attributes)
  if name == 'item'
    case
    when @xmlpath[/securityGroupInfo$/] then @item = { :ip_permissions => [] }
    when @xmlpath[/ipPermissions$/]     then @ip_permission = { :groups => [], :ip_ranges => [] }
    when @xmlpath[/groups$/]            then @group = {}
    end
  end
end