Class: Nutriscore::UK::GeneralScore
- Inherits:
-
Object
- Object
- Nutriscore::UK::GeneralScore
- Includes:
- GeneralLessHealthy
- Defined in:
- lib/nutriscore/uk/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, fibres_method: :aoac) ⇒ GeneralScore
constructor
A new instance of GeneralScore.
- #inspect ⇒ Object
- #score ⇒ Object
Methods included from GeneralLessHealthy
Constructor Details
#initialize(nutrients, fibres_method: :aoac) ⇒ GeneralScore
Returns a new instance of GeneralScore.
17 18 19 20 21 |
# File 'lib/nutriscore/uk/general_score.rb', line 17 def initialize(nutrients, fibres_method: :aoac) @nutrients = Nutriscore::Common::Nutrients.wrap(nutrients) @positive = PositiveScore.new(@nutrients, fibres_method: fibres_method) @negative = NegativeScore.new(@nutrients) end |
Instance Attribute Details
#negative ⇒ Object (readonly)
Returns the value of attribute negative.
11 12 13 |
# File 'lib/nutriscore/uk/general_score.rb', line 11 def negative @negative end |
#positive ⇒ Object (readonly)
Returns the value of attribute positive.
11 12 13 |
# File 'lib/nutriscore/uk/general_score.rb', line 11 def positive @positive end |
Class Method Details
.nutrient_keys ⇒ Object
13 14 15 |
# File 'lib/nutriscore/uk/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/uk/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/uk/general_score.rb', line 23 def score @negative.score - @positive.score end |