Class: Menu_DSL
- Inherits:
-
Object
- Object
- Menu_DSL
- Includes:
- Comparable
- Defined in:
- lib/menu/codigo_menu_dsl.rb
Instance Attribute Summary collapse
-
#ingesta ⇒ Object
readonly
Returns the value of attribute ingesta.
-
#nombre ⇒ Object
readonly
Returns the value of attribute nombre.
-
#plato ⇒ Object
readonly
Returns the value of attribute plato.
-
#porcentajes ⇒ Object
readonly
Returns the value of attribute porcentajes.
-
#titulo ⇒ Object
readonly
Returns the value of attribute titulo.
-
#vct ⇒ Object
readonly
Returns the value of attribute vct.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #get_desc_plato(i) ⇒ Object
- #get_grasas ⇒ Object
- #get_hidratos ⇒ Object
- #get_ingesta_diaria ⇒ Object
- #get_plato(i) ⇒ Object
- #get_platos ⇒ Object
- #get_proteinas ⇒ Object
- #get_titulo ⇒ Object
- #get_vct ⇒ Object
- #ingesta_(opciones = {}) ⇒ Object
-
#initialize(nombre, &block) ⇒ Menu_DSL
constructor
A new instance of Menu_DSL.
- #plato_(opciones = {}) ⇒ Object
- #porcentajes_(opciones = {}) ⇒ Object
- #titulo_(name) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(nombre, &block) ⇒ Menu_DSL
Returns a new instance of Menu_DSL.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/menu/codigo_menu_dsl.rb', line 5 def initialize(nombre, &block) @nombre = nombre @titulo = "" @ingesta = "" @plato = [] @vct = 0 @porcentajes = [] if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Attribute Details
#ingesta ⇒ Object (readonly)
Returns the value of attribute ingesta.
3 4 5 |
# File 'lib/menu/codigo_menu_dsl.rb', line 3 def ingesta @ingesta end |
#nombre ⇒ Object (readonly)
Returns the value of attribute nombre.
3 4 5 |
# File 'lib/menu/codigo_menu_dsl.rb', line 3 def nombre @nombre end |
#plato ⇒ Object (readonly)
Returns the value of attribute plato.
3 4 5 |
# File 'lib/menu/codigo_menu_dsl.rb', line 3 def plato @plato end |
#porcentajes ⇒ Object (readonly)
Returns the value of attribute porcentajes.
3 4 5 |
# File 'lib/menu/codigo_menu_dsl.rb', line 3 def porcentajes @porcentajes end |
#titulo ⇒ Object (readonly)
Returns the value of attribute titulo.
3 4 5 |
# File 'lib/menu/codigo_menu_dsl.rb', line 3 def titulo @titulo end |
#vct ⇒ Object (readonly)
Returns the value of attribute vct.
3 4 5 |
# File 'lib/menu/codigo_menu_dsl.rb', line 3 def vct @vct end |
Instance Method Details
#<=>(other) ⇒ Object
26 27 28 |
# File 'lib/menu/codigo_menu_dsl.rb', line 26 def <=> (other) vct <=> other.vct end |
#==(other) ⇒ Object
22 23 24 |
# File 'lib/menu/codigo_menu_dsl.rb', line 22 def == (other) vct == other.vct && porcentajes==other.porcentajes end |
#get_desc_plato(i) ⇒ Object
42 43 44 |
# File 'lib/menu/codigo_menu_dsl.rb', line 42 def get_desc_plato(i) "#{@plato[i][0]}, #{@plato[i][1]}, #{@plato[i][2]} " end |
#get_grasas ⇒ Object
66 67 68 |
# File 'lib/menu/codigo_menu_dsl.rb', line 66 def get_grasas @porcentajes[1] end |
#get_hidratos ⇒ Object
70 71 72 |
# File 'lib/menu/codigo_menu_dsl.rb', line 70 def get_hidratos @porcentajes[2] end |
#get_ingesta_diaria ⇒ Object
46 47 48 |
# File 'lib/menu/codigo_menu_dsl.rb', line 46 def get_ingesta_diaria @ingesta end |
#get_plato(i) ⇒ Object
50 51 52 |
# File 'lib/menu/codigo_menu_dsl.rb', line 50 def get_plato(i) @plato[i][0] end |
#get_platos ⇒ Object
54 55 56 |
# File 'lib/menu/codigo_menu_dsl.rb', line 54 def get_platos @plato end |
#get_proteinas ⇒ Object
62 63 64 |
# File 'lib/menu/codigo_menu_dsl.rb', line 62 def get_proteinas @porcentajes[0] end |
#get_titulo ⇒ Object
38 39 40 |
# File 'lib/menu/codigo_menu_dsl.rb', line 38 def get_titulo @titulo end |
#get_vct ⇒ Object
58 59 60 |
# File 'lib/menu/codigo_menu_dsl.rb', line 58 def get_vct @vct end |
#ingesta_(opciones = {}) ⇒ Object
78 79 80 81 82 83 |
# File 'lib/menu/codigo_menu_dsl.rb', line 78 def ingesta_ (opciones = {}) ingest = "" ingest << "#{opciones[:min]}" if opciones[:min] ingest<<"-#{opciones[:max]} %" if opciones[:max] @ingesta = ingest end |
#plato_(opciones = {}) ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'lib/menu/codigo_menu_dsl.rb', line 85 def plato_ (opciones = {}) grams = "" descripcion = "" porcion = "" grams = "#{opciones[:gramos]} g" if opciones[:gramos] descripcion = opciones[:descripcion] if opciones[:descripcion] porcion = opciones[:porcion] if opciones[:porcion] @plato.push([descripcion,porcion,grams]) end |
#porcentajes_(opciones = {}) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/menu/codigo_menu_dsl.rb', line 95 def porcentajes_ (opciones = {}) @vct = "#{opciones[:vct]} %" if opciones[:vct] proteinas = "" grasas = "" hidratos = "" proteinas = "#{opciones[:proteinas]} %" if opciones[:proteinas] grasas = "#{opciones[:grasas]} %" if opciones[:grasas] hidratos = "#{opciones[:hidratos]} %" if opciones[:hidratos] @porcentajes.push(proteinas) @porcentajes.push(grasas) @porcentajes.push(hidratos) end |
#titulo_(name) ⇒ Object
74 75 76 |
# File 'lib/menu/codigo_menu_dsl.rb', line 74 def titulo_ (name) @titulo = name end |
#to_s ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/menu/codigo_menu_dsl.rb', line 30 def to_s title = "#{@titulo} ( #{@ingesta} )\n " for i in 0..@plato.size-1 title +="- #{@plato[i][0]}, #{@plato[i][1]}, #{@plato[i][2]} \n" end title += "- V.C.T. |% #{@vct} kcal | #{@porcentajes[0]} - #{@porcentajes[1]} - #{@porcentajes[2]}" end |