Class: RightAws::Ec2::QEc2DescribeImagesParser

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

Overview


PARSERS: Images

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



391
392
393
# File 'lib/ec2/right_ec2_images.rb', line 391

def reset
  @result = []
end

#tagend(name) ⇒ Object



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/ec2/right_ec2_images.rb', line 350

def tagend(name)
  case name
  when 'imageId'         then @item[:aws_id]            = @text
  when 'imageLocation'   then @item[:aws_location]      = @text
  when 'imageState'      then @item[:aws_state]         = @text
  when 'imageOwnerId'    then @item[:aws_owner]         = @text
  when 'isPublic'        then @item[:aws_is_public]     = @text == 'true' ? true : false
  when 'productCode'     then (@item[:aws_product_codes] ||= []) << @text
  when 'architecture'    then @item[:aws_architecture]  = @text
  when 'imageType'       then @item[:aws_image_type]    = @text
  when 'kernelId'        then @item[:aws_kernel_id]     = @text
  when 'ramdiskId'       then @item[:aws_ramdisk_id]    = @text
  when 'platform'        then @item[:aws_platform]      = @text
  when 'imageOwnerAlias' then @item[:image_owner_alias] = @text
  when 'name'            then @item[:name]              = @text
  when 'description'     then @item[:description]       = @text
  when 'rootDeviceType'  then @item[:root_device_type]  = @text
  when 'rootDeviceName'  then @item[:root_device_name]  = @text
  when 'imageClass'      then @item[:image_class]       = @text
  when 'virtualizationType' then @item[:virtualization_type] = @text
  when 'hypervisor'      then @item [:hypervisor]       = @text
  else
    case full_tag_name
    when %r{/stateReason/code$}    then @item[:state_reason_code]    = @text.to_i
    when %r{/stateReason/message$} then @item[:state_reason_message] = @text
    when %r{/blockDeviceMapping/item} # no trailing $
      case name
      when 'deviceName'          then @block_device_mapping[:device_name]                = @text
      when 'virtualName'         then @block_device_mapping[:virtual_name]               = @text
      when 'volumeSize'          then @block_device_mapping[:ebs_volume_size]            = @text.to_i
      when 'snapshotId'          then @block_device_mapping[:ebs_snapshot_id]            = @text
      when 'deleteOnTermination' then @block_device_mapping[:ebs_delete_on_termination]  = @text == 'true' ? true : false
      when 'item'                then @item[:block_device_mappings]                    << @block_device_mapping
      end
    when %r{/tagSet/item/key$}   then @aws_tag[:key]               = @text
    when %r{/tagSet/item/value$} then @aws_tag[:value]             = @text
    when %r{/tagSet/item$}       then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
    when %r{/imagesSet/item$}    then @result                     << @item
    end
  end
end

#tagstart(name, attributes) ⇒ Object

:nodoc:



339
340
341
342
343
344
345
346
347
348
349
# File 'lib/ec2/right_ec2_images.rb', line 339

def tagstart(name, attributes)
  case full_tag_name
  when %r{/imagesSet/item$}
    @item = { :tags => {} }
  when %r{/blockDeviceMapping/item$}
    @item[:block_device_mappings] ||= []
    @block_device_mapping = {}
  when %r{/tagSet/item$}
    @aws_tag = {}
  end
end