Method: Beercalc.extractAddition

Defined in:
lib/beercalc.rb

.extractAddition(target_gu, total_gu, extractType) ⇒ Object

EXTRACT ADDITION param target_gu: number - Target Total Gravity in Gravity Units param total_gu: number - Total Gravity from Mash in Gravity Units param extract: string/number - should be ‘LME’ or ‘DME’ or custom value



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/beercalc.rb', line 168

def self.extractAddition(target_gu, total_gu, extractType)
  # Preset values for LME and DME, or account for a custom value
  if extractType == 'LME'
    extract = 38
  elsif extractType == 'DME'
    extract = 45
  elsif extractType.is_a?(Numeric)
    extract = extractType
  end

  unless !target_gu.is_a?(Numeric) || !total_gu.is_a?(Numeric) || !extract.is_a?(Numeric)
    addition = (target_gu - total_gu).to_f / extract
  else
    addition = nil
  end
  return addition  
end