Class: Menu
Overview
Clase que representa un Menu
Instance Attribute Summary collapse
-
#conjunto_platos ⇒ Object
Returns the value of attribute conjunto_platos.
-
#conjunto_valores ⇒ Object
Returns the value of attribute conjunto_valores.
-
#ingestas ⇒ Object
Returns the value of attribute ingestas.
-
#name ⇒ Object
Returns the value of attribute name.
-
#porcentaje ⇒ Object
Returns the value of attribute porcentaje.
-
#titulo ⇒ Object
Returns the value of attribute titulo.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Método de Modulo Comparable#### Comparamos el valor calórico total.
- #ingesta(options = {}) ⇒ Object
-
#initialize(name, &bloque) ⇒ Menu
constructor
A new instance of Menu.
- #plato(options = {}) ⇒ Object
- #porcentajes(options = {}) ⇒ Object
- #titulo_(titulos) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, &bloque) ⇒ Menu
Returns a new instance of Menu.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/menu_dietetico/menu.rb', line 8 def initialize(name, &bloque) self.name = name self.titulo = "" self.ingestas = [] self.conjunto_platos = [] self.conjunto_valores = [] if block_given? if bloque.arity == 1 yield self else instance_eval(&bloque) end end end |
Instance Attribute Details
#conjunto_platos ⇒ Object
Returns the value of attribute conjunto_platos.
6 7 8 |
# File 'lib/menu_dietetico/menu.rb', line 6 def conjunto_platos @conjunto_platos end |
#conjunto_valores ⇒ Object
Returns the value of attribute conjunto_valores.
6 7 8 |
# File 'lib/menu_dietetico/menu.rb', line 6 def conjunto_valores @conjunto_valores end |
#ingestas ⇒ Object
Returns the value of attribute ingestas.
6 7 8 |
# File 'lib/menu_dietetico/menu.rb', line 6 def ingestas @ingestas end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/menu_dietetico/menu.rb', line 6 def name @name end |
#porcentaje ⇒ Object
Returns the value of attribute porcentaje.
6 7 8 |
# File 'lib/menu_dietetico/menu.rb', line 6 def porcentaje @porcentaje end |
#titulo ⇒ Object
Returns the value of attribute titulo.
6 7 8 |
# File 'lib/menu_dietetico/menu.rb', line 6 def titulo @titulo end |
Instance Method Details
#<=>(other) ⇒ Object
Método de Modulo Comparable#### Comparamos el valor calórico total
71 72 73 |
# File 'lib/menu_dietetico/menu.rb', line 71 def <=> (other) @vct<=> other.vct end |
#ingesta(options = {}) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/menu_dietetico/menu.rb', line 28 def ingesta( = {}) ingesta = "#{[:min]}, " if [:min] ingesta << "#{[:max]}" if [:max] ingestas << ingesta ingestas << "\n" end |
#plato(options = {}) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/menu_dietetico/menu.rb', line 35 def plato( = {}) platos = "#{[:descripcion]}, " if [:descripcion] platos << "#{[:porcion]}, " if [:porcion] platos << "#{[:gramos]}" if [:gramos] conjunto_platos << platos conjunto_platos << "\n" end |
#porcentajes(options = {}) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/menu_dietetico/menu.rb', line 43 def porcentajes( = {}) porcentaje = "#{[:vct]}, " if [:vct] porcentaje << "#{[:proteinas]} - " if [:proteinas] porcentaje << "#{[:grasas]} - " if [:grasas] porcentaje << "#{[:hidratos]}" if [:hidratos] conjunto_valores << porcentaje conjunto_valores << "\n" end |
#titulo_(titulos) ⇒ Object
24 25 26 |
# File 'lib/menu_dietetico/menu.rb', line 24 def titulo_(titulos) self.titulo = titulos end |
#to_s ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/menu_dietetico/menu.rb', line 52 def to_s output = "\n" output << titulo output << "\n" output << "#{ingesta.join()}" #conjunto_platos.each_with_index do |conjunto_platos, index| # output << "\n#{conjunto_platos}" #end #conjunto_valores.each_with_index do |conjunto_valores, index| # output << "\n#{conjunto_valores}" #end output << "#{conjunto_platos.join()}\n" output << "#{conjunto_valores.join()}\n\n" end |