Class: FlexStationData::Presenters::SampleHash
- Inherits:
-
Object
- Object
- FlexStationData::Presenters::SampleHash
- Includes:
- Callable[:present]
- Defined in:
- lib/flex_station_data/presenters/sample_hash.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#quality_control ⇒ Object
readonly
Returns the value of attribute quality_control.
-
#sample ⇒ Object
readonly
Returns the value of attribute sample.
-
#times ⇒ Object
readonly
Returns the value of attribute times.
Instance Method Summary collapse
- #errors ⇒ Object
- #errors? ⇒ Boolean
- #errors_hash ⇒ Object
-
#initialize(times, sample, **options) ⇒ SampleHash
constructor
A new instance of SampleHash.
- #present ⇒ Object
- #regression_hash ⇒ Object
- #wells_hash ⇒ Object
Constructor Details
#initialize(times, sample, **options) ⇒ SampleHash
Returns a new instance of SampleHash.
14 15 16 17 18 |
# File 'lib/flex_station_data/presenters/sample_hash.rb', line 14 def initialize(times, sample, **) @times = times @sample = sample @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/flex_station_data/presenters/sample_hash.rb', line 12 def @options end |
#quality_control ⇒ Object (readonly)
Returns the value of attribute quality_control.
12 13 14 |
# File 'lib/flex_station_data/presenters/sample_hash.rb', line 12 def quality_control @quality_control end |
#sample ⇒ Object (readonly)
Returns the value of attribute sample.
12 13 14 |
# File 'lib/flex_station_data/presenters/sample_hash.rb', line 12 def sample @sample end |
#times ⇒ Object (readonly)
Returns the value of attribute times.
12 13 14 |
# File 'lib/flex_station_data/presenters/sample_hash.rb', line 12 def times @times end |
Instance Method Details
#errors ⇒ Object
20 21 22 |
# File 'lib/flex_station_data/presenters/sample_hash.rb', line 20 def errors @errors ||= SampleQuality.call(sample, **).reject(&:good?) end |
#errors? ⇒ Boolean
24 25 26 |
# File 'lib/flex_station_data/presenters/sample_hash.rb', line 24 def errors? errors.present? end |
#errors_hash ⇒ Object
28 29 30 |
# File 'lib/flex_station_data/presenters/sample_hash.rb', line 28 def errors_hash { "error" => errors.first&.to_s } end |
#present ⇒ Object
42 43 44 |
# File 'lib/flex_station_data/presenters/sample_hash.rb', line 42 def present { "sample" => sample.label }.merge(wells_hash).merge(errors_hash).merge(regression_hash) end |
#regression_hash ⇒ Object
36 37 38 39 40 |
# File 'lib/flex_station_data/presenters/sample_hash.rb', line 36 def regression_hash return SampleRegressionHash.headers.zip([]).to_h if errors? SampleRegressionHash.present(times, sample.mean, **).transform_values(&:first) end |
#wells_hash ⇒ Object
32 33 34 |
# File 'lib/flex_station_data/presenters/sample_hash.rb', line 32 def wells_hash { "wells" => sample.wells.join(", ") } end |