Class: Food
- Inherits:
-
FoodAbstract
- Object
- FoodAbstract
- Food
- Includes:
- Comparable
- Defined in:
- lib/food/food_class.rb
Overview
Class for Food that inherit FoodAbstract
Instance Attribute Summary collapse
- #group_name ⇒ Object readonly
Attributes inherited from FoodAbstract
#energetic_content, #glucid_quantity, #lipid_quantity, #name, #protein_quantity
Instance Method Summary collapse
-
#<=>(food) ⇒ String
Essential comparating for using Comparable Module.
-
#initialize(name, protein_energy_pair, glucid_energy_pair, lipid_energy_pair, group_name) ⇒ Food
constructor
Constructor of Food with the group name.
-
#to_s ⇒ String
Return string with the output for the food calling the father.
Methods inherited from FoodAbstract
Constructor Details
#initialize(name, protein_energy_pair, glucid_energy_pair, lipid_energy_pair, group_name) ⇒ Food
Constructor of Food with the group name
77 78 79 80 |
# File 'lib/food/food_class.rb', line 77 def initialize(name, protein_energy_pair, glucid_energy_pair, lipid_energy_pair, group_name) @group_name = group_name super(name, protein_energy_pair, glucid_energy_pair, lipid_energy_pair) end |
Instance Attribute Details
#group_name ⇒ Object (readonly)
69 70 71 |
# File 'lib/food/food_class.rb', line 69 def group_name @group_name end |
Instance Method Details
#<=>(food) ⇒ String
Essential comparating for using Comparable Module
90 91 92 93 |
# File 'lib/food/food_class.rb', line 90 def <=> (food) raise unless food.is_a?Food return self.energetic_content <=> food.energetic_content end |
#to_s ⇒ String
Return string with the output for the food calling the father
84 85 86 |
# File 'lib/food/food_class.rb', line 84 def to_s "Grupo: #{@group_name} | " + super end |