Class: Nutriscore::FR::GeneralScore

Inherits:
Object
  • Object
show all
Includes:
GeneralScoreClass
Defined in:
lib/nutriscore/fr/general_score.rb

Direct Known Subclasses

CheeseScore, SpecificScore

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GeneralScoreClass

#score_class

Constructor Details

#initialize(nutrients) ⇒ GeneralScore

Returns a new instance of GeneralScore.



17
18
19
20
21
# File 'lib/nutriscore/fr/general_score.rb', line 17

def initialize(nutrients)
  @nutrients = Nutriscore::Common::Nutrients.wrap(nutrients)
  @positive = PositiveScore.new(@nutrients)
  @negative = NegativeScore.new(@nutrients)
end

Instance Attribute Details

#negativeObject (readonly)

Returns the value of attribute negative.



11
12
13
# File 'lib/nutriscore/fr/general_score.rb', line 11

def negative
  @negative
end

#positiveObject (readonly)

Returns the value of attribute positive.



11
12
13
# File 'lib/nutriscore/fr/general_score.rb', line 11

def positive
  @positive
end

Class Method Details

.nutrient_keysObject



13
14
15
# File 'lib/nutriscore/fr/general_score.rb', line 13

def self.nutrient_keys
  PositiveScore.nutrient_keys | NegativeScore.nutrient_keys
end

Instance Method Details

#inspectObject



27
28
29
30
# File 'lib/nutriscore/fr/general_score.rb', line 27

def inspect
  "#<#{self.class} score=#{score} " +
    "positive_score=#{@positive.inspect} negative_score=#{@negative.inspect}>"
end

#scoreObject



23
24
25
# File 'lib/nutriscore/fr/general_score.rb', line 23

def score
  @negative.score - @positive.score
end