Class: Menufinal
- Inherits:
-
Object
- Object
- Menufinal
- Defined in:
- lib/dieta/Menu.rb
Instance Attribute Summary collapse
-
#etiqueta ⇒ Object
readonly
Returns the value of attribute etiqueta.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #ingesta(ran = {}) ⇒ Object
-
#initialize(et, &bloque) ⇒ Menufinal
constructor
A new instance of Menufinal.
- #mostrar_platos ⇒ Object
- #mostrar_porcentajes ⇒ Object
- #plato(caracteristicas = {}) ⇒ Object
- #porcentajes(tantos = {}) ⇒ Object
- #titulo(t) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(et, &bloque) ⇒ Menufinal
Returns a new instance of Menufinal.
8 9 10 11 12 13 14 15 16 |
# File 'lib/dieta/Menu.rb', line 8 def initialize(et, &bloque) @etiqueta = et @title = nil @rango_ingesta = [] @platos = [] @porcentaje = [] instance_eval &bloque if block_given? end |
Instance Attribute Details
#etiqueta ⇒ Object (readonly)
Returns the value of attribute etiqueta.
7 8 9 |
# File 'lib/dieta/Menu.rb', line 7 def etiqueta @etiqueta end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/dieta/Menu.rb', line 7 def title @title end |
Instance Method Details
#ingesta(ran = {}) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/dieta/Menu.rb', line 22 def ingesta(ran = {}) if ran[:min] @rango_ingesta[0] = ran[:min] end if ran[:max] @rango_ingesta[1] = ran[:max] end end |
#mostrar_platos ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/dieta/Menu.rb', line 47 def mostrar_platos @platos.each do |i| puts " plato :descripcion => #{i[:descripcion]} :racion => #{i[:racion]} :gramos => #{i[:gramos]}" puts "\t" end end |
#mostrar_porcentajes ⇒ Object
58 59 60 61 62 63 |
# File 'lib/dieta/Menu.rb', line 58 def mostrar_porcentajes puts "Porcentajes: " puts "Vct: #{@porcentaje[0]} || Proteinas: #{@porcentaje[1]}|| Grasas: #{@porcentaje[2]}|| Hidratos: #{@porcentaje[3]}." end |
#plato(caracteristicas = {}) ⇒ Object
31 32 33 |
# File 'lib/dieta/Menu.rb', line 31 def plato (caracteristicas = {}) @platos << Plato.new(caracteristicas[:descripcion],caracteristicas[:racion],caracteristicas[:gramos]) end |
#porcentajes(tantos = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dieta/Menu.rb', line 35 def porcentajes (tantos = {}) i = 0 @porcentaje[i] = tantos[:vct] i += 1 @porcentaje[i] = tantos[:proteinas] i += 1 @porcentaje[i] = tantos[:grasas] i += 1 @porcentajes[i] = tantos[:hidratos] end |
#titulo(t) ⇒ Object
18 19 20 |
# File 'lib/dieta/Menu.rb', line 18 def titulo(t) @title = t end |
#to_s ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/dieta/Menu.rb', line 65 def to_s puts "Menu: #{etiqueta}" puts "Título: #{title}" puts " \n ************************\n" puts " Ingesta: #{@rango_ingesta[0]} %-#{@rango_ingesta[1]}%" mostrar_platos mostrar_porcentajes end |