Class: Fog::Parsers::AWS::CloudWatch::ListMetrics

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/aws/parsers/cloud_watch/list_metrics.rb

Instance Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from Base

#attr_value, #characters, #initialize, #value

Constructor Details

This class inherits a constructor from Fog::Parsers::Base

Instance Method Details

#end_element(name) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fog/aws/parsers/cloud_watch/list_metrics.rb', line 33

def end_element(name)
  case name
  when 'Name', 'Value'
    @dimension[name] = value
  when 'Namespace', 'MetricName'
    @metric[name] = value
  when 'Dimensions'
    @in_dimensions = false
  when 'NextMarker'
    @response['ListMetricsResult'][name] = value
  when 'RequestId'
    @response['ResponseMetadata'][name] = value
  when 'member'
    if !@in_dimensions
      @response['ListMetricsResult']['Metrics'] << @metric
      reset_metric
    else
      @metric['Dimensions'] << @dimension
    end
  end
end

#resetObject



8
9
10
11
# File 'lib/fog/aws/parsers/cloud_watch/list_metrics.rb', line 8

def reset
  @response = { 'ListMetricsResult' => {'Metrics' => []}, 'ResponseMetadata' => {} }
  reset_metric
end

#reset_dimensionObject



17
18
19
# File 'lib/fog/aws/parsers/cloud_watch/list_metrics.rb', line 17

def reset_dimension
  @dimension = {}
end

#reset_metricObject



13
14
15
# File 'lib/fog/aws/parsers/cloud_watch/list_metrics.rb', line 13

def reset_metric
  @metric = {'Dimensions' => []}
end

#start_element(name, attrs = []) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/aws/parsers/cloud_watch/list_metrics.rb', line 21

def start_element(name, attrs = [])
  super
  case name
  when 'Dimensions'
    @in_dimensions = true
  when 'member'
    if @in_dimensions
      reset_dimension
    end
  end
end