Class: Deltacloud::Metric::Property
- Inherits:
-
Object
- Object
- Deltacloud::Metric::Property
- Defined in:
- lib/deltacloud/models/metric.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
- #generate_mock_values! ⇒ Object
-
#initialize(name, values = nil) ⇒ Property
constructor
A new instance of Property.
- #to_hash(context) ⇒ Object
Constructor Details
#initialize(name, values = nil) ⇒ Property
Returns a new instance of Property.
57 58 59 |
# File 'lib/deltacloud/models/metric.rb', line 57 def initialize(name, values=nil) @name, @values = name, values end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
55 56 57 |
# File 'lib/deltacloud/models/metric.rb', line 55 def name @name end |
#values ⇒ Object
Returns the value of attribute values.
55 56 57 |
# File 'lib/deltacloud/models/metric.rb', line 55 def values @values end |
Instance Method Details
#generate_mock_values! ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/deltacloud/models/metric.rb', line 68 def generate_mock_values! generator = lambda { |name, kind| v = { :min => (1+(rand(49))), :max => (50+(rand(50))) } (name == 'cpuUtilization') ? v[kind].to_f/100 : v[kind] } @values = (0..5).map do |v_id| { :minimum => min = generator.call(@name, :min), :maximum => max = generator.call(@name, :max), :average => (min+max)/2, :timestamp => (Time.now-v_id).to_i, :unit => unit_for(@name) } end end |
#to_hash(context) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/deltacloud/models/metric.rb', line 61 def to_hash(context) { :name => name, :values => values } end |