Class: Flagstack::Telemetry::Metric
- Inherits:
-
Object
- Object
- Flagstack::Telemetry::Metric
- Defined in:
- lib/flagstack/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 ⇒ 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.
6 7 8 9 10 |
# File 'lib/flagstack/telemetry/metric.rb', line 6 def initialize(key, result, time = Time.now) @key = key.to_s @result = !!result @time = time.to_i / 60 * 60 # Round to minute end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/flagstack/telemetry/metric.rb', line 4 def key @key end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
4 5 6 |
# File 'lib/flagstack/telemetry/metric.rb', line 4 def result @result end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
4 5 6 |
# File 'lib/flagstack/telemetry/metric.rb', line 4 def time @time end |
Instance Method Details
#as_json ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/flagstack/telemetry/metric.rb', line 12 def as_json { "key" => key, "time" => time, "result" => result } end |
#eql?(other) ⇒ Boolean Also known as: ==
20 21 22 23 24 25 |
# File 'lib/flagstack/telemetry/metric.rb', line 20 def eql?(other) self.class.eql?(other.class) && @key == other.key && @time == other.time && @result == other.result end |
#hash ⇒ Object
28 29 30 |
# File 'lib/flagstack/telemetry/metric.rb', line 28 def hash [self.class, @key, @time, @result].hash end |