class Nutriscore::FR::FatsScore

this is for vegetable and animal fats and oils

Public Class Methods

nutrient_keys() click to toggle source
# File lib/nutriscore/fr/fats_score.rb, line 10
def self.nutrient_keys
  [:fat_saturated, :fat_total]
end

Public Instance Methods

fat_saturated() click to toggle source
# File lib/nutriscore/fr/fats_score.rb, line 18
def fat_saturated
  score_value(fat_saturated_pct, 0..10) do |v|
    if    v < 10 then  0
    elsif v < 16 then  1
    elsif v < 22 then  2
    elsif v < 28 then  3
    elsif v < 34 then  4
    elsif v < 40 then  5
    elsif v < 46 then  6
    elsif v < 52 then  7
    elsif v < 58 then  8
    elsif v < 64 then  9
    else              10
    end
  end
end
score() click to toggle source
# File lib/nutriscore/fr/fats_score.rb, line 14
def score
  fat_saturated
end

Private Instance Methods

fat_saturated_pct() click to toggle source
# File lib/nutriscore/fr/fats_score.rb, line 37
def fat_saturated_pct
  fat_saturated = @nutrients.fat_saturated
  fat_total = @nutrients.fat_total
  fat_saturated * 100 / fat_total if fat_saturated && fat_total
end