Class: TimeSeries
- Inherits:
-
Object
- Object
- TimeSeries
- Defined in:
- lib/rearview/templates/monitor.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#label ⇒ Object
Returns the value of attribute label.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ts) ⇒ TimeSeries
constructor
A new instance of TimeSeries.
- #to_s ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(ts) ⇒ TimeSeries
Returns a new instance of TimeSeries.
38 39 40 41 42 43 44 |
# File 'lib/rearview/templates/monitor.rb', line 38 def initialize(ts) @label = ts.first["metric"] @entries = ts.map { |t| Metric.new(lambda { self.label }, t["timestamp"], t["value"]) } def @entries.to_s "[ #{self.join ", "} ]" end end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
36 37 38 |
# File 'lib/rearview/templates/monitor.rb', line 36 def entries @entries end |
#label ⇒ Object
Returns the value of attribute label.
35 36 37 |
# File 'lib/rearview/templates/monitor.rb', line 35 def label @label end |
Class Method Details
.to_s ⇒ Object
41 42 43 |
# File 'lib/rearview/templates/monitor.rb', line 41 def @entries.to_s "[ #{self.join ", "} ]" end |
Instance Method Details
#to_s ⇒ Object
50 51 52 |
# File 'lib/rearview/templates/monitor.rb', line 50 def to_s "{ label: #{@label}, entries: [ #{@entries.join ", "} ] }" end |
#values ⇒ Object
46 47 48 |
# File 'lib/rearview/templates/monitor.rb', line 46 def values @entries.map { |e| e.value } end |