Class: TimeSeries

Inherits:
Object
  • Object
show all
Defined in:
lib/rearview/templates/monitor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#entriesObject (readonly)

Returns the value of attribute entries.



36
37
38
# File 'lib/rearview/templates/monitor.rb', line 36

def entries
  @entries
end

#labelObject

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_sObject



41
42
43
# File 'lib/rearview/templates/monitor.rb', line 41

def @entries.to_s
  "[ #{self.join ", "} ]"
end

Instance Method Details

#to_sObject



50
51
52
# File 'lib/rearview/templates/monitor.rb', line 50

def to_s
  "{ label: #{@label}, entries: [ #{@entries.join ", "} ] }"
end

#valuesObject



46
47
48
# File 'lib/rearview/templates/monitor.rb', line 46

def values
  @entries.map { |e| e.value }
end