Class: Menu
- Inherits:
-
Object
- Object
- Menu
- Defined in:
- lib/Dieta/Menu.rb
Instance Attribute Summary collapse
-
#etiqueta ⇒ Object
Returns the value of attribute etiqueta.
-
#ingest ⇒ Object
Returns the value of attribute ingest.
-
#platos ⇒ Object
Returns the value of attribute platos.
-
#porcentaje ⇒ Object
Returns the value of attribute porcentaje.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #ingesta(options = {}) ⇒ Object
-
#initialize(etiqueta, &block) ⇒ Menu
constructor
A new instance of Menu.
- #plato(options = {}) ⇒ Object
- #porcentajes(options = {}) ⇒ Object
- #titulo(options = {}) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(etiqueta, &block) ⇒ Menu
Returns a new instance of Menu.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/Dieta/Menu.rb', line 4 def initialize(etiqueta,&block) self.etiqueta=etiqueta self.title = "" self.ingest = [] self.platos = [] self.porcentaje = [] if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Attribute Details
#etiqueta ⇒ Object
Returns the value of attribute etiqueta.
2 3 4 |
# File 'lib/Dieta/Menu.rb', line 2 def etiqueta @etiqueta end |
#ingest ⇒ Object
Returns the value of attribute ingest.
2 3 4 |
# File 'lib/Dieta/Menu.rb', line 2 def ingest @ingest end |
#platos ⇒ Object
Returns the value of attribute platos.
2 3 4 |
# File 'lib/Dieta/Menu.rb', line 2 def platos @platos end |
#porcentaje ⇒ Object
Returns the value of attribute porcentaje.
2 3 4 |
# File 'lib/Dieta/Menu.rb', line 2 def porcentaje @porcentaje end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/Dieta/Menu.rb', line 2 def title @title end |
Instance Method Details
#ingesta(options = {}) ⇒ Object
24 25 26 27 |
# File 'lib/Dieta/Menu.rb', line 24 def ingesta( = {}) ingest << "#{[:min]}" ingest << "#{[:max]}" end |
#plato(options = {}) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/Dieta/Menu.rb', line 29 def plato( = {}) plat = [] plat << "#{[:descripcion]}" plat << "#{[:porcion]}" plat << "#{[:gramos]}" platos << plat end |
#porcentajes(options = {}) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/Dieta/Menu.rb', line 36 def porcentajes( = {}) porcentaje << "#{[:vct]}" porcentaje << "#{[:proteinas]}" porcentaje << "#{[:grasas]}" porcentaje << "#{[:hidratos]}" end |
#titulo(options = {}) ⇒ Object
20 21 22 |
# File 'lib/Dieta/Menu.rb', line 20 def titulo( = {}) title << "#{[:titulo]}" end |
#to_s ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/Dieta/Menu.rb', line 43 def to_s output = "#{title}\n" output << "#{'#' * title.size}\n\n" output << "Entre{" ingest.each do |p| output << p + " " end output << "}\n" platos.each do |p| p.each do |x| output << x + " " end output << "g \n" end porcentaje.each do |p| output << p + " " end output end |