Class: Nutriscore::FR::GeneralScore
- Inherits:
-
Object
- Object
- Nutriscore::FR::GeneralScore
- Includes:
- GeneralScoreClass
- Defined in:
- lib/nutriscore/fr/general_score.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#negative ⇒ Object
readonly
Returns the value of attribute negative.
-
#positive ⇒ Object
readonly
Returns the value of attribute positive.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(nutrients) ⇒ GeneralScore
constructor
A new instance of GeneralScore.
- #inspect ⇒ Object
- #score ⇒ Object
Methods included from GeneralScoreClass
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
#negative ⇒ Object (readonly)
Returns the value of attribute negative.
11 12 13 |
# File 'lib/nutriscore/fr/general_score.rb', line 11 def negative @negative end |
#positive ⇒ Object (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_keys ⇒ Object
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
#inspect ⇒ Object
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 |
#score ⇒ Object
23 24 25 |
# File 'lib/nutriscore/fr/general_score.rb', line 23 def score @negative.score - @positive.score end |