Class: Nutriscore::FR::SpecificScore

Inherits:
GeneralScore show all
Defined in:
lib/nutriscore/fr/specific_score.rb

Overview

this is for general products

Instance Attribute Summary

Attributes inherited from GeneralScore

#negative, #positive

Instance Method Summary collapse

Methods inherited from GeneralScore

#initialize, #inspect, nutrient_keys

Methods included from GeneralScoreClass

#score_class

Constructor Details

This class inherits a constructor from Nutriscore::FR::GeneralScore

Instance Method Details

#scoreObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/nutriscore/fr/specific_score.rb', line 8

def score
  if @negative.score.min < 11 || @positive.fvnp.max >= 5
    @negative.score - @positive.score
  elsif @negative.score.max >= 11 && @positive.fvnp.min < 5
    @negative.score - @positive.score_without_proteins
  else
    Range.new(
      @negative.score.min - @positive.score.max,
      @negative.score.max - @positive.score_without_proteins.min
    )
  end
end