Class: SAAL::Chart

Inherits:
Object
  • Object
show all
Defined in:
lib/chart.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, defs, sensors, opts = {}) ⇒ Chart

Returns a new instance of Chart.



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/chart.rb', line 4

def initialize(name, defs, sensors, opts={})
  @name = name
  @defs = defs
  @alignlabels = (defs['alignlabels'] || :center).to_sym
  @sensors = defs['sensors'].map{|name| sensors.send(name)} 
  @num = defs['last']
  @periods = defs['periods']
  @alt = defs['alt']
  @description = defs['description']
  @datarange = ChartDataRange.new(defs.merge(:now => opts[:now]))
end

Instance Attribute Details

#alignlabelsObject (readonly)

Returns the value of attribute alignlabels.



3
4
5
# File 'lib/chart.rb', line 3

def alignlabels
  @alignlabels
end

#altObject (readonly)

Returns the value of attribute alt.



3
4
5
# File 'lib/chart.rb', line 3

def alt
  @alt
end

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/chart.rb', line 3

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/chart.rb', line 3

def name
  @name
end

#numObject (readonly)

Returns the value of attribute num.



3
4
5
# File 'lib/chart.rb', line 3

def num
  @num
end

#periodsObject (readonly)

Returns the value of attribute periods.



3
4
5
# File 'lib/chart.rb', line 3

def periods
  @periods
end

#sensorsObject (readonly)

Returns the value of attribute sensors.



3
4
5
# File 'lib/chart.rb', line 3

def sensors
  @sensors
end

Instance Method Details

#average(num = nil) ⇒ Object



20
21
22
# File 'lib/chart.rb', line 20

def average(num=nil)
  get_data(:average, num)
end

#fromObject



32
33
34
# File 'lib/chart.rb', line 32

def from
  @datarange.from
end

#maximum(num = nil) ⇒ Object



28
29
30
# File 'lib/chart.rb', line 28

def maximum(num=nil)
  get_data(:maximum, num)
end

#minimum(num = nil) ⇒ Object



24
25
26
# File 'lib/chart.rb', line 24

def minimum(num=nil)
  get_data(:minimum, num)
end

#periodnamesObject



16
17
18
# File 'lib/chart.rb', line 16

def periodnames
  @datarange.periodnames
end

#toObject



35
36
37
# File 'lib/chart.rb', line 35

def to
  @datarange.to
end