Class: DataInput::DataSeries

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeDataSeries

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_valueFloat (readonly)

Returns maximal value of the data, initial = nil.

Returns:

  • (Float)

    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_valueFloat (readonly)

Returns minimal value of the data, initial = nil.

Returns:

  • (Float)

    minimal value of the data, initial = nil



12
13
14
# File 'lib/data/data_series.rb', line 12

def min_value
  @min_value
end

#seriesArray (readonly)

Returns Array of data sets, initial empty.

Returns:

  • (Array)

    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

Parameters:



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