class SAAL::Chart
Attributes
alignlabels[R]
alt[R]
description[R]
name[R]
num[R]
periods[R]
sensors[R]
Public Class Methods
new(name, defs, sensors, opts={})
click to toggle source
# File lib/chart.rb 4 def initialize(name, defs, sensors, opts={}) 5 @name = name 6 @defs = defs 7 @alignlabels = (defs['alignlabels'] || :center).to_sym 8 @sensors = defs['sensors'].map{|sname| sensors.send(sname)} 9 @num = defs['last'] 10 @periods = defs['periods'] 11 @alt = defs['alt'] 12 @description = defs['description'] 13 @datarange = ChartDataRange.new(defs.merge(:now => opts[:now])) 14 end
Public Instance Methods
average(num=nil)
click to toggle source
# File lib/chart.rb 20 def average(num=nil) 21 get_data(:average, num) 22 end
from()
click to toggle source
# File lib/chart.rb 32 def from 33 @datarange.from 34 end
maximum(num=nil)
click to toggle source
# File lib/chart.rb 28 def maximum(num=nil) 29 get_data(:maximum, num) 30 end
minimum(num=nil)
click to toggle source
# File lib/chart.rb 24 def minimum(num=nil) 25 get_data(:minimum, num) 26 end
periodnames()
click to toggle source
# File lib/chart.rb 16 def periodnames 17 @datarange.periodnames 18 end
to()
click to toggle source
# File lib/chart.rb 35 def to 36 @datarange.to 37 end
Private Instance Methods
get_data(method, num)
click to toggle source
# File lib/chart.rb 40 def get_data(method, num) 41 n = num || 1 42 h = {} 43 @sensors.each do |s| 44 data = @datarange.get_data(method,s,n) 45 h[s.name.to_sym] = num ? data : data[0] 46 end 47 h 48 end