Class: RightAws::Ec2::QEc2DescribeSpotInstanceParser

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

Overview

:nodoc:

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



385
386
387
# File 'lib/ec2/right_ec2_spot_instances.rb', line 385

def reset
  @result = []
end

#tagend(name) ⇒ Object



339
340
341
342
343
344
345
346
347
348
349
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
# File 'lib/ec2/right_ec2_spot_instances.rb', line 339

def tagend(name)
  case name
  when 'spotInstanceRequestId' then @item[:spot_instance_request_id]= @text
  when 'spotPrice'             then @item[:spot_price]              = @text.to_f
  when 'type'                  then @item[:type]                    = @text
  when 'state'                 then @item[:state]                   = @text
  when 'code'                  then @item[:fault_code]              = @text
  when 'message'               then @item[:fault_message]           = @text
  when 'validFrom'             then @item[:valid_from]              = @text
  when 'validUntil'            then @item[:valid_until]             = @text
  when 'launchGroup'           then @item[:launch_group]            = @text
  when 'availabilityZoneGroup' then @item[:availability_zone_group] = @text
  when 'imageId'               then @item[:image_id]                = @text
  when 'keyName'               then @item[:key_name]                = @text
  when 'userData'              then @item[:userData]                = @text
  when 'data'                  then @item[:data]                    = @text
  when 'addressingType'        then @item[:addressing_type]         = @text
  when 'instanceType'          then @item[:instance_type]           = @text
  when 'availabilityZone'      then @item[:availability_zone]       = @text
  when 'kernelId'              then @item[:kernel_id]               = @text
  when 'ramdiskId'             then @item[:ramdisk_id]              = @text
  when 'subnetId'              then @item[:subnet_id]               = @text
  when 'instanceId'            then @item[:instance_id]             = @text
  when 'createTime'            then @item[:create_time]             = @text
  when 'productDescription'    then @item[:product_description]     = @text
  when 'groupId'               then (@item[:groups] ||= [])        << @text
  else
    case full_tag_name
    when %r{monitoring/enabled$}
      @item[:monitoring_enabled] = @text == 'true'
    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{spotInstanceRequestSet/item$} then @result << @item
    end
  end
end

#tagstart(name, attributes) ⇒ Object



328
329
330
331
332
333
334
335
336
337
338
# File 'lib/ec2/right_ec2_spot_instances.rb', line 328

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