Sha256: 9205f883052538745605c55d089787f3dcdc9a7e77841b56dbfd7734f25ae716

Contents?: true

Size: 1020 Bytes

Versions: 31

Compression:

Stored size: 1020 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/pd"
require_dependency "renalware/pd/apd/glucose_calculator"

module Renalware
  module PD
    module APD
      class CalculateVolumes
        def initialize(regime)
          raise ArgumentError("Not an APD regime") unless regime.apd?

          @regime = decorate(regime)
        end

        def call
          regime.overnight_volume = regime.calculated_overnight_volume
          regime.daily_volume = regime.calculated_daily_volume
          regime.glucose_volume_low_strength = regime.volume_of_glucose_at_strength(:low)
          regime.glucose_volume_medium_strength = regime.volume_of_glucose_at_strength(:medium)
          regime.glucose_volume_high_strength = regime.volume_of_glucose_at_strength(:high)
        end

        private

        attr_reader :regime

        def decorate(regime)
          klass = regime.tidal? ? TidalRegimeCalculations : NonTidalRegimeCalculations
          klass.new(regime)
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.1.0 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.167 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.166 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.165 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.164 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.163 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.162 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.161 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.160 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.159 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.158 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.157 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.156 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.155 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.153 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.152 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.151 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.149 app/models/renalware/pd/apd/calculate_volumes.rb
renalware-core-2.0.148 app/models/renalware/pd/apd/calculate_volumes.rb