Class: Deltacloud::Client::Metric

Inherits:
Base
  • Object
show all
Includes:
Deltacloud::Client::Methods::Metric
Defined in:
lib/deltacloud/client/models/metric.rb

Defined Under Namespace

Classes: Property

Instance Attribute Summary collapse

Attributes inherited from Base

#description, #name, #obj_id, #url

Class Method Summary collapse

Methods included from Deltacloud::Client::Methods::Metric

#metric, #metrics

Methods inherited from Base

#client, #connection, convert, #entrypoint, from_collection, #id, #initialize, #original_body, #to_s, #update_instance_variables!, validate_attrs!

Methods included from Helpers::XmlHelper

#extract_xml_body

Methods included from Deltacloud::Client::Methods::Api

#api_uri, #current_driver, #current_provider, #feature?, #features, #must_support!, #path, #support?, #supported_collections, #version

Methods included from Helpers::Model

#error, #from_collection, #from_resource, #model

Constructor Details

This class inherits a constructor from Deltacloud::Client::Base

Instance Attribute Details

#entityObject (readonly)

Inherited attributes: :_id, :name, :description



23
24
25
# File 'lib/deltacloud/client/models/metric.rb', line 23

def entity
  @entity
end

#propertiesObject (readonly)

Returns the value of attribute properties.



24
25
26
# File 'lib/deltacloud/client/models/metric.rb', line 24

def properties
  @properties
end

Class Method Details

.parse(xml_body) ⇒ Object

Parse the Metric entity from XML body

  • xml_body -> Deltacloud API XML representation of the metric



61
62
63
64
65
66
67
68
69
70
# File 'lib/deltacloud/client/models/metric.rb', line 61

def self.parse(xml_body)
  {
    :entity => xml_body.text_at(:entity),
    :properties => xml_body.xpath('properties/*').map { |p|
      Property.new(p.name, p.xpath('sample').map { |s|
        s.xpath('property').map { |v| [v['name'], v['value']] }
      })
    }
  }
end