Class: Tube::AttributeUpdater::Molarity

Inherits:
Base
  • Object
show all
Defined in:
app/models/tube/attribute_updater.rb

Overview

Updates concentration or molarity

Instance Attribute Summary

Attributes inherited from Base

#qc_result, #tube

Instance Method Summary collapse

Methods inherited from Base

#initialize, #original_value, #target_value

Constructor Details

This class inherits a constructor from Tube::AttributeUpdater::Base

Instance Method Details

#molarityObject


73
74
75
# File 'app/models/tube/attribute_updater.rb', line 73

def molarity
  original_value.convert_to('nmol/l').scalar
end

#molarity?Boolean

Returns:

  • (Boolean)

69
70
71
# File 'app/models/tube/attribute_updater.rb', line 69

def molarity?
  original_value.compatible?('nmol/l')
end

#updateObject


77
78
79
# File 'app/models/tube/attribute_updater.rb', line 77

def update
  tube.update!(concentration: molarity) if molarity?
end