Class: FlexStationData::Presenters::SampleRegressionHash
- Inherits:
-
Object
- Object
- FlexStationData::Presenters::SampleRegressionHash
- Includes:
- Callable[:present]
- Defined in:
- lib/flex_station_data/presenters/sample_regression_hash.rb
Constant Summary collapse
- PRODUCTS =
{ slope: "slope", intercept: "intercept", r_squared: "R²", quality: "quality" }.freeze
Instance Attribute Summary collapse
-
#min_r_squared ⇒ Object
readonly
Returns the value of attribute min_r_squared.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#sample_values ⇒ Object
readonly
Returns the value of attribute sample_values.
-
#times ⇒ Object
readonly
Returns the value of attribute times.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(times, *sample_values, min_r_squared: nil, **options) ⇒ SampleRegressionHash
constructor
A new instance of SampleRegressionHash.
- #present ⇒ Object
- #sample_regressions ⇒ Object
Constructor Details
#initialize(times, *sample_values, min_r_squared: nil, **options) ⇒ SampleRegressionHash
Returns a new instance of SampleRegressionHash.
20 21 22 23 24 25 |
# File 'lib/flex_station_data/presenters/sample_regression_hash.rb', line 20 def initialize(times, *sample_values, min_r_squared: nil, **) @times = times @sample_values = sample_values @min_r_squared = min_r_squared @options = end |
Instance Attribute Details
#min_r_squared ⇒ Object (readonly)
Returns the value of attribute min_r_squared.
18 19 20 |
# File 'lib/flex_station_data/presenters/sample_regression_hash.rb', line 18 def min_r_squared @min_r_squared end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
18 19 20 |
# File 'lib/flex_station_data/presenters/sample_regression_hash.rb', line 18 def @options end |
#sample_values ⇒ Object (readonly)
Returns the value of attribute sample_values.
18 19 20 |
# File 'lib/flex_station_data/presenters/sample_regression_hash.rb', line 18 def sample_values @sample_values end |
#times ⇒ Object (readonly)
Returns the value of attribute times.
18 19 20 |
# File 'lib/flex_station_data/presenters/sample_regression_hash.rb', line 18 def times @times end |
Class Method Details
.headers ⇒ Object
39 40 41 |
# File 'lib/flex_station_data/presenters/sample_regression_hash.rb', line 39 def self.headers PRODUCTS.values end |
Instance Method Details
#present ⇒ Object
33 34 35 36 37 |
# File 'lib/flex_station_data/presenters/sample_regression_hash.rb', line 33 def present PRODUCTS.each_with_object({}) do |(method, label), memo| memo[label] = sample_regressions.map(&method) end end |
#sample_regressions ⇒ Object
27 28 29 30 31 |
# File 'lib/flex_station_data/presenters/sample_regression_hash.rb', line 27 def sample_regressions @sample_regressions ||= sample_values.map do |values| FlexStationData::LinearRegression.new(times, values, min_r_squared: min_r_squared) end end |