class PKUlib

Public Class Methods

average(*numbers) click to toggle source

average method to find a finite number in phe range

# File lib/pkulib.rb, line 21
def self.average(*numbers)
    numbers.reduce(:+).to_f / numbers.size
end
floz2ml(floz) click to toggle source

Conversions for beverages/liquids to grams

# File lib/pkulib.rb, line 12
def self.floz2ml(floz)
  ml = floz / 0.033814
end
litre2ml(litre) click to toggle source
# File lib/pkulib.rb, line 16
def self.litre2ml(litre)
  ml = litre / 0.001
end
mg2gram(milligrams) click to toggle source
# File lib/pkulib.rb, line 7
def self.mg2gram(milligrams)
  grams = milligrams / 1000.0
end
oz2gram(ounces) click to toggle source

Conversions for non-liquid foods to grams

# File lib/pkulib.rb, line 3
def self.oz2gram(ounces)
  grams = ounces / 0.035274
end
phecalc(protein,qualifier) click to toggle source

Perform the conversion of protein to milligrams of phenylalanine

# File lib/pkulib.rb, line 26
def self.phecalc(protein,qualifier)
  if protein < 0.5
    min = 0
    max = 0.5 * 64.5
  elsif qualifier == "fruit"
    min = protein * 20
    max = protein * 30
  elsif qualifier == "veg"
    min = protein * 20
    max = protein * 40
  else
    min = protein * 20
    max = protein * 64.5
  end
{
    :minimum => min,
    :maximum => max
}
end