class DietaDia
Constants
- VERSION
Attributes
almuerzo[R]
cena[R]
conversiones[R]
desayuno[R]
nombre[R]
Public Class Methods
new(nombre) { |self| ... }
click to toggle source
# File lib/NutrientesEdu/DietaDiaria.rb, line 8 def initialize(nombre, &bloque) @conversiones = [ ["1 rodaja", 20], ["1 porcion", 100], ["1 taza", 180], ["1/2 cucharon",18], ["1 pieza", 135], ["1 vaso", 100]] @nombre = nombre @desayuno = Menu.new() @almuerzo = Menu.new() @cena = Menu.new() if block_given? if bloque.arity == 1 yield self else instance_eval(&bloque) end end end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/NutrientesEdu/DietaDiaria.rb, line 41 def <=>(other) kcal <=> other.kcal end
is_enough(persona)
click to toggle source
# File lib/NutrientesEdu/DietaDiaria.rb, line 35 def is_enough(persona) x = kcal return (persona.g_en_total <= x * 1.1) && (persona.g_en_total >= x * 0.9) end
kcal()
click to toggle source
# File lib/NutrientesEdu/DietaDiaria.rb, line 30 def kcal @desayuno.kcal + @almuerzo.kcal + @cena.kcal end
to_s()
click to toggle source
# File lib/NutrientesEdu/DietaDiaria.rb, line 47 def to_s texto = @nombre texto << "\n#{'=' * @nombre.size}\n" texto << "Composicion nutricional: \n" texto << "Desayuno: " texto << "\n" texto << @desayuno.to_s texto << "Almuerzo: " texto << "\n" texto << @almuerzo.to_s texto << "Cena: " texto << "\n" texto << @cena.to_s texto << "Kcal totales: " texto << "#{kcal}" texto << "\n" return texto end