Class: Alimento
- Inherits:
-
Object
- Object
- Alimento
- Includes:
- Comparable
- Defined in:
- lib/NutrientesEdu/NutrientesEdu.rb
Instance Attribute Summary collapse
-
#azucar ⇒ Object
readonly
Returns the value of attribute azucar.
-
#carbs ⇒ Object
readonly
Returns the value of attribute carbs.
-
#grasas ⇒ Object
readonly
Returns the value of attribute grasas.
-
#grsat ⇒ Object
readonly
Returns the value of attribute grsat.
-
#nombre ⇒ Object
readonly
Returns the value of attribute nombre.
-
#protein ⇒ Object
readonly
Returns the value of attribute protein.
-
#sal ⇒ Object
readonly
Returns the value of attribute sal.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(nombre, grasas, grsat, carbs, azucar, protein, sal) ⇒ Alimento
constructor
A new instance of Alimento.
- #to_s ⇒ Object
- #val_ener ⇒ Object
Constructor Details
#initialize(nombre, grasas, grsat, carbs, azucar, protein, sal) ⇒ Alimento
Returns a new instance of Alimento.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/NutrientesEdu/NutrientesEdu.rb', line 9 def initialize(nombre, grasas, grsat, carbs, azucar, protein, sal) @nombre = nombre @grasas = grasas @grsat = grsat @carbs = carbs @azucar = azucar @protein = protein @sal = sal end |
Instance Attribute Details
#azucar ⇒ Object (readonly)
Returns the value of attribute azucar.
7 8 9 |
# File 'lib/NutrientesEdu/NutrientesEdu.rb', line 7 def azucar @azucar end |
#carbs ⇒ Object (readonly)
Returns the value of attribute carbs.
7 8 9 |
# File 'lib/NutrientesEdu/NutrientesEdu.rb', line 7 def carbs @carbs end |
#grasas ⇒ Object (readonly)
Returns the value of attribute grasas.
7 8 9 |
# File 'lib/NutrientesEdu/NutrientesEdu.rb', line 7 def grasas @grasas end |
#grsat ⇒ Object (readonly)
Returns the value of attribute grsat.
7 8 9 |
# File 'lib/NutrientesEdu/NutrientesEdu.rb', line 7 def grsat @grsat end |
#nombre ⇒ Object (readonly)
Returns the value of attribute nombre.
7 8 9 |
# File 'lib/NutrientesEdu/NutrientesEdu.rb', line 7 def nombre @nombre end |
#protein ⇒ Object (readonly)
Returns the value of attribute protein.
7 8 9 |
# File 'lib/NutrientesEdu/NutrientesEdu.rb', line 7 def protein @protein end |
#sal ⇒ Object (readonly)
Returns the value of attribute sal.
7 8 9 |
# File 'lib/NutrientesEdu/NutrientesEdu.rb', line 7 def sal @sal end |
Instance Method Details
#<=>(other) ⇒ Object
30 31 32 |
# File 'lib/NutrientesEdu/NutrientesEdu.rb', line 30 def <=> (other) val_ener <=> other.val_ener end |
#to_s ⇒ Object
25 26 27 28 |
# File 'lib/NutrientesEdu/NutrientesEdu.rb', line 25 def to_s "Nombre: #{@nombre}, Grasas: #{@grasas}, Saturadas: #{@grsat}, Carbohidratos: #{@carbs}, Azucar: #{@azucar}, Proteinas: #{@protein}, Sal: #{@sal} Kcal: #{val_ener} " end |
#val_ener ⇒ Object
20 21 22 |
# File 'lib/NutrientesEdu/NutrientesEdu.rb', line 20 def val_ener (grasas*9+carbs*4+protein*4) end |