Class: DataInput::DataSeries
- Inherits:
-
Object
- Object
- DataInput::DataSeries
- Defined in:
- lib/data/data_series.rb
Overview
Class to represent a series of multiple data sets with the extreme values of the whole data series
Instance Attribute Summary collapse
-
#max_value ⇒ Float
readonly
Maximal value of the data, initial = nil.
-
#min_value ⇒ Float
readonly
Minimal value of the data, initial = nil.
-
#series ⇒ Array
readonly
Array of data sets, initial empty.
Instance Method Summary collapse
-
#add_data_set(data_set) ⇒ Object
adds a data set to the array and checks if there are new maximum and minimum values.
-
#initialize ⇒ DataSeries
constructor
initialization min_value and max_value are initialized with nil because the extreme values are not necessarily present at this moment.
Constructor Details
#initialize ⇒ DataSeries
initialization min_value and max_value are initialized with nil because the extreme values are not necessarily present at this moment
21 22 23 24 25 26 |
# File 'lib/data/data_series.rb', line 21 def initialize @series = Array.new() @min_value = nil @max_value = nil end |
Instance Attribute Details
#max_value ⇒ Float (readonly)
Returns maximal value of the data, initial = nil.
14 15 16 |
# File 'lib/data/data_series.rb', line 14 def max_value @max_value end |
#min_value ⇒ Float (readonly)
Returns minimal value of the data, initial = nil.
12 13 14 |
# File 'lib/data/data_series.rb', line 12 def min_value @min_value end |
#series ⇒ Array (readonly)
Returns Array of data sets, initial empty.
16 17 18 |
# File 'lib/data/data_series.rb', line 16 def series @series end |
Instance Method Details
#add_data_set(data_set) ⇒ Object
adds a data set to the array and checks if there are new maximum and minimum values
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/data/data_series.rb', line 31 def add_data_set(data_set) @series << data_set if (@min_value == nil || @min_value > data_set.min_value) @min_value = data_set.min_value end if (@max_value == nil || @max_value < data_set.max_value) @max_value = data_set.max_value end end |