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.
-
#plat ⇒ Object
Returns the value of attribute plat.
-
#porcentaje ⇒ Object
Returns the value of attribute porcentaje.
-
#title2 ⇒ Object
Returns the value of attribute title2.
Instance Method Summary collapse
- #ingesta(bloque = {}) ⇒ Object
-
#initialize(etiqueta, &block) ⇒ Menu
constructor
A new instance of Menu.
- #plato(bloque = {}) ⇒ Object
- #porcentajes(bloque = {}) ⇒ Object
-
#titulo(bloque = {}) ⇒ Object
def TITULO.
- #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 18 |
# File 'lib/Dieta/menu.rb', line 4 def initialize(etiqueta, &block) self.etiqueta = etiqueta self.title2 = "" self.ingest = [] self.plat = [] 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 |
#plat ⇒ Object
Returns the value of attribute plat.
2 3 4 |
# File 'lib/Dieta/menu.rb', line 2 def plat @plat end |
#porcentaje ⇒ Object
Returns the value of attribute porcentaje.
2 3 4 |
# File 'lib/Dieta/menu.rb', line 2 def porcentaje @porcentaje end |
#title2 ⇒ Object
Returns the value of attribute title2.
2 3 4 |
# File 'lib/Dieta/menu.rb', line 2 def title2 @title2 end |
Instance Method Details
#ingesta(bloque = {}) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/Dieta/menu.rb', line 25 def ingesta(bloque = {}) inges = [] inges << "#{bloque[:min]}" inges << "#{bloque[:max]}" ingest << inges end |
#plato(bloque = {}) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/Dieta/menu.rb', line 32 def plato(bloque = {}) pl = [] pl << "#{bloque[:descripcion]}" pl << "#{bloque[:porcion]}" pl << "#{bloque[:gramos]}" plat << pl end |
#porcentajes(bloque = {}) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/Dieta/menu.rb', line 40 def porcentajes(bloque = {}) porc = [] porc << "#{bloque[:vct]}" porc << "#{bloque[:proteinas]}" porc << "#{bloque[:grasas]}" porc << "#{bloque[:hidratos]}" porcentaje << porc end |
#titulo(bloque = {}) ⇒ Object
def TITULO
21 22 23 |
# File 'lib/Dieta/menu.rb', line 21 def titulo(bloque = {}) title2 << "#{bloque[:title]}" end |
#to_s ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/Dieta/menu.rb', line 49 def to_s output = "\n\n#{title2}" output << "\n#{'=' * title2.size}\n" ingest.each do |iii| output << "Min: #{iii[0]}" output << ", Max: #{iii[1]}\n" end plat.each do |pltt| output << "Plato: #{pltt[0]}" output << ", PorciĆ³n: #{pltt[1]}" output << ", Gramos: #{pltt[2]}\n" end porcentaje.each do |prc| output << "VCT: #{prc[0]}" output << ", Proteinas: #{prc[1]}" output << ", Grasas: #{prc[2]}" output << ", Hidratos: #{prc[3]}\n" end output end |