Class: RightAws::Ec2::QEc2DescribeReservedInstancesParser

Inherits:
RightAWSParser
  • Object
show all
Defined in:
lib/ec2/right_ec2_reserved_instances.rb

Overview


PARSERS: ReservedInstances

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



186
187
188
# File 'lib/ec2/right_ec2_reserved_instances.rb', line 186

def reset
  @result = []
end

#tagend(name) ⇒ Object



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/ec2/right_ec2_reserved_instances.rb', line 159

def tagend(name)
  case name
  when 'reservedInstancesId' then @item[:aws_id]                  = @text
  when 'instanceType'        then @item[:aws_instance_type]       = @text
  when 'availabilityZone'    then @item[:aws_availability_zone]   = @text
  when 'duration'            then @item[:aws_duration]            = @text.to_i
  when 'usagePrice'          then @item[:aws_usage_price]         = @text.to_f
  when 'fixedPrice'          then @item[:aws_fixed_price]         = @text.to_f
  when 'instanceCount'       then @item[:aws_instance_count]      = @text.to_i
  when 'productDescription'  then @item[:aws_product_description] = @text
  when 'state'               then @item[:aws_state]               = @text
  when 'start'               then @item[:aws_start]               = @text
  when 'instanceTenancy'     then @item[:instance_tenancy]        = @text
  when 'currencyCode'        then @item[:currency_code]           = @text
  when 'offeringType'        then @item[:offering_type]           = @text
  else
    case full_tag_name
    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{/recurringCharges/item/frequency$} then @recurring_charge[:frequency] = @text
    when %r{/recurringCharges/item/amount$}    then @recurring_charge[:amount]    = @text
    when %r{/recurringCharges/item$}           then (@item[:recurring_charges]  ||= []) << @recurring_charge
    when %r{/reservedInstancesSet/item$}       then @result                      << @item
    end
  end
end

#tagstart(name, attributes) ⇒ Object

:nodoc:



152
153
154
155
156
157
158
# File 'lib/ec2/right_ec2_reserved_instances.rb', line 152

def tagstart(name, attributes)
  case full_tag_name
  when %r{/recurringCharges/item$}     then @recurring_charge = {}
  when %r{/tagSet/item$}               then @aws_tag = {}
  when %r{/reservedInstancesSet/item$} then @item    = { :tags=> {} }
  end
end