Class: Deltacloud::Metric
- Defined in:
- lib/deltacloud/models/metric.rb
Defined Under Namespace
Classes: Property
Constant Summary collapse
- MOCK_METRICS_NAMES =
[ 'cpuUtilization', 'diskReadRequestCount', 'diskReadSector', 'diskWriteRequestCount', 'diskWriteSector', 'nicInputByte', 'nicInputPacket', 'nicOutputByte', 'nicOutputPacket' ]
Instance Attribute Summary collapse
-
#entity ⇒ Object
Returns the value of attribute entity.
-
#properties ⇒ Object
Returns the value of attribute properties.
Attributes inherited from BaseModel
Instance Method Summary collapse
Methods inherited from BaseModel
attr_accessor, attributes, #attributes, #id, #initialize, #to_entity
Constructor Details
This class inherits a constructor from Deltacloud::BaseModel
Instance Attribute Details
#entity ⇒ Object
Returns the value of attribute entity.
19 20 21 |
# File 'lib/deltacloud/models/metric.rb', line 19 def entity @entity end |
#properties ⇒ Object
Returns the value of attribute properties.
20 21 22 |
# File 'lib/deltacloud/models/metric.rb', line 20 def properties @properties end |
Instance Method Details
#add_property(name, values = nil) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/deltacloud/models/metric.rb', line 38 def add_property(name, values=nil) self.properties ||= [] return self if self.properties.any? { |p| p.name == name } self.properties << Property.new(name, values) self end |
#to_hash(context) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/deltacloud/models/metric.rb', line 45 def to_hash(context) { :id => self.id, :href => context.metric_url(self.id), :entity => entity, :properties => properties.map { |p| p.to_hash(context) } } end |
#unknown? ⇒ Boolean
34 35 36 |
# File 'lib/deltacloud/models/metric.rb', line 34 def unknown? self.entity == :unknown end |