Class: Flipper::Cloud::Telemetry::Metric
- Inherits:
-
Object
- Object
- Flipper::Cloud::Telemetry::Metric
- Defined in:
- lib/flipper/cloud/telemetry/metric.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(key, result, time = Time.now) ⇒ Metric
constructor
A new instance of Metric.
Constructor Details
#initialize(key, result, time = Time.now) ⇒ Metric
Returns a new instance of Metric.
7 8 9 10 11 |
# File 'lib/flipper/cloud/telemetry/metric.rb', line 7 def initialize(key, result, time = Time.now) @key = key @result = result @time = time.to_i / 60 * 60 end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/flipper/cloud/telemetry/metric.rb', line 5 def key @key end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
5 6 7 |
# File 'lib/flipper/cloud/telemetry/metric.rb', line 5 def result @result end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
5 6 7 |
# File 'lib/flipper/cloud/telemetry/metric.rb', line 5 def time @time end |
Instance Method Details
#as_json(options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/flipper/cloud/telemetry/metric.rb', line 13 def as_json( = {}) data = { "key" => key.to_s, "time" => time, "result" => result, } if [:with] data.merge!([:with]) end data end |
#eql?(other) ⇒ Boolean Also known as: ==
27 28 29 30 |
# File 'lib/flipper/cloud/telemetry/metric.rb', line 27 def eql?(other) self.class.eql?(other.class) && @key == other.key && @time == other.time && @result == other.result end |
#hash ⇒ Object
33 34 35 |
# File 'lib/flipper/cloud/telemetry/metric.rb', line 33 def hash [self.class, @key, @time, @result].hash end |