Class: Parsers::QuantParser
- Inherits:
-
Object
- Object
- Parsers::QuantParser
- Defined in:
- app/models/parsers/quant_parser.rb
Defined Under Namespace
Classes: InvalidFile
Constant Summary collapse
- HEADER_IDENTIFIER =
'Headers'
- LOCATION_HEADER =
'Well Location'
- COLUMN_MAPS =
{ 'concentration' => %w[concentration ng/ul], 'molarity' => %w[molarity nmol/l], 'volume' => %w[volume ul], 'rin' => %w[RIN RIN] }.freeze
- VALUE_REGEX =
Extract decimals from columns. Ignores preceding ( and allows optional decimal point Any characters after the digits are ignored. eg. 12.345 => 12.345 13 => 13 (45.2) => 45.2 sausages => nil 34 ng/ul => 35
/\A\({0,1}(?<decimal>\d+\.{0,1}\d*)/
Class Method Summary collapse
Instance Method Summary collapse
- #each_well_and_parameters ⇒ Object
-
#initialize(content) ⇒ QuantParser
constructor
A new instance of QuantParser.
Constructor Details
#initialize(content) ⇒ QuantParser
Returns a new instance of QuantParser.
31 32 33 |
# File 'app/models/parsers/quant_parser.rb', line 31 def initialize(content) @content = content end |
Class Method Details
.headers_index(content) ⇒ Object
35 36 37 |
# File 'app/models/parsers/quant_parser.rb', line 35 def self.headers_index(content) content.find_index { |l| l[0] == HEADER_IDENTIFIER } end |
.parses?(content) ⇒ Boolean
39 40 41 |
# File 'app/models/parsers/quant_parser.rb', line 39 def self.parses?(content) (content[0][0] == 'Assay Plate Barcode') && headers_index(content) end |
Instance Method Details
#each_well_and_parameters ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'app/models/parsers/quant_parser.rb', line 43 def each_well_and_parameters data_section.each do |row| # If location is nil or blank, ignore the row next if row[location_index].nil? || row[location_index].strip.blank? yield(row[location_index], qc_values_for_row(row)) end end |