Class: Parsers::DilutionParser
- Inherits:
-
Object
- Object
- Parsers::DilutionParser
- Defined in:
- app/models/parsers/dilution_parser.rb
Overview
A dilution parser wraps other parsers and passes the relevant information on to the parent plate at the provided dilution factor.
Constant Summary collapse
- UNSCALED =
Parameters which get passed on unchanged
['RIN'].freeze
- SCALED =
Parameters which get multiplied by the scale factor
%w[concentration molarity].freeze
Instance Attribute Summary collapse
-
#original_parser ⇒ Object
readonly
Other parameters (eg. volume) will not propagate.
-
#scale_factor ⇒ Object
readonly
Other parameters (eg. volume) will not propagate.
Instance Method Summary collapse
-
#assay_type ⇒ String
The assay type, appending ‘from -dilution’ to distinguish from direct measurement.
-
#each_well_and_parameters {|String, Hash| ... } ⇒ Object
Yield each well and the scaled attributes for each.
-
#initialize(original_parser, scale_factor) ⇒ DilutionParser
constructor
Create a parse to pass to parent plates.
Constructor Details
#initialize(original_parser, scale_factor) ⇒ DilutionParser
Create a parse to pass to parent plates
23 24 25 26 |
# File 'app/models/parsers/dilution_parser.rb', line 23 def initialize(original_parser, scale_factor) @original_parser = original_parser @scale_factor = scale_factor end |
Instance Attribute Details
#original_parser ⇒ Object (readonly)
Other parameters (eg. volume) will not propagate
15 16 17 |
# File 'app/models/parsers/dilution_parser.rb', line 15 def original_parser @original_parser end |
#scale_factor ⇒ Object (readonly)
Other parameters (eg. volume) will not propagate
15 16 17 |
# File 'app/models/parsers/dilution_parser.rb', line 15 def scale_factor @scale_factor end |
Instance Method Details
#assay_type ⇒ String
The assay type, appending ‘from -dilution’ to distinguish from direct measurement
32 33 34 |
# File 'app/models/parsers/dilution_parser.rb', line 32 def assay_type "#{original_parser.assay_type} from dilution" end |
#each_well_and_parameters {|String, Hash| ... } ⇒ Object
Yield each well and the scaled attributes for each
40 41 42 43 44 45 46 47 48 |
# File 'app/models/parsers/dilution_parser.rb', line 40 def each_well_and_parameters original_parser.each_well_and_parameters do |well, parameters| adjusted_parameters = parameters.slice(*UNSCALED) SCALED.each do |attribute| adjusted_parameters[attribute] = parameters[attribute] * scale_factor if parameters[attribute] end yield well, adjusted_parameters end end |