class GerbilCharts::Models::TimeSeriesGraphModel
TimeSeriesGraphModel
¶ ↑
time series graph model (special case of monotonous) we expect discrete points, mainly the x_values are interpreted as timestamp therefore we can construct the appropriate preset axis labels.
Eg. We can create round labels such as 8:15 instead of 8:16:47
Public Class Methods
new(name,opt={})
click to toggle source
Calls superclass method
GerbilCharts::Models::MonotonousGraphModel::new
# File lib/gerbilcharts/models/time_series_graph_model.rb, line 12 def initialize(name,opt={}) super(name,opt) @rounderx=RoundTimeRange @roundery=RoundRange end
Public Instance Methods
add(timeobj, val)
click to toggle source
we add Timeval objects (those that respond to tv_sec)
Calls superclass method
GerbilCharts::Models::MonotonousGraphModel#add
# File lib/gerbilcharts/models/time_series_graph_model.rb, line 19 def add(timeobj, val) super normalize_time_input(timeobj),val end
crop_older(cutofftime)
click to toggle source
crop older than the given timestamp
# File lib/gerbilcharts/models/time_series_graph_model.rb, line 24 def crop_older(cutofftime) crop_at(normalize_time_input(cutofftime)) end
is_timeseries?()
click to toggle source
just a check if we need time series
# File lib/gerbilcharts/models/time_series_graph_model.rb, line 29 def is_timeseries? return true end
normalize_time_input(tin)
click to toggle source
normalize input timestamp
# File lib/gerbilcharts/models/time_series_graph_model.rb, line 34 def normalize_time_input(tin) if tin.is_a? Time return tin elsif tin.is_a? Integer if tin > 0xffffffff return Time.at(tin>>32) else return Time.at(tin) end end raise "Timeseries graph model expects Time, or Integer represent time" end