Class: Menu

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/dieta/menu.rb

Direct Known Subclasses

Menu_alimento, Menu_edad

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(titulo, porcentaje, platos, vct, proteinas, grasas, hidratos) ⇒ Menu

Returns a new instance of Menu.



6
7
8
# File 'lib/dieta/menu.rb', line 6

def initialize titulo, porcentaje, platos, vct, proteinas, grasas, hidratos
	@titulo, @porcentaje, @platos, @vct, @proteinas, @grasas, @hidratos = titulo, porcentaje, platos, vct, proteinas, grasas, hidratos
end

Instance Attribute Details

#grasasObject (readonly)

Returns the value of attribute grasas.



5
6
7
# File 'lib/dieta/menu.rb', line 5

def grasas
  @grasas
end

#hidratosObject (readonly)

Returns the value of attribute hidratos.



5
6
7
# File 'lib/dieta/menu.rb', line 5

def hidratos
  @hidratos
end

#platosObject (readonly)

Returns the value of attribute platos.



5
6
7
# File 'lib/dieta/menu.rb', line 5

def platos
  @platos
end

#porcentajeObject (readonly)

Returns the value of attribute porcentaje.



5
6
7
# File 'lib/dieta/menu.rb', line 5

def porcentaje
  @porcentaje
end

#proteinasObject (readonly)

Returns the value of attribute proteinas.



5
6
7
# File 'lib/dieta/menu.rb', line 5

def proteinas
  @proteinas
end

#tituloObject (readonly)

Returns the value of attribute titulo.



5
6
7
# File 'lib/dieta/menu.rb', line 5

def titulo
  @titulo
end

#vctObject (readonly)

Returns the value of attribute vct.



5
6
7
# File 'lib/dieta/menu.rb', line 5

def vct
  @vct
end

Instance Method Details

#<=>(otro) ⇒ Object



39
40
41
# File 'lib/dieta/menu.rb', line 39

def <=>(otro)
	titulo<=>otro.titulo
end

#get_grasasObject



33
34
35
# File 'lib/dieta/menu.rb', line 33

def get_grasas
	@grasas
end

#get_hidratosObject



36
37
38
# File 'lib/dieta/menu.rb', line 36

def get_hidratos
	@hidratos
end

#get_plato(i) ⇒ Object



12
13
14
# File 'lib/dieta/menu.rb', line 12

def get_plato i
	@platos[i]
end

#get_porcentajeObject



21
22
23
# File 'lib/dieta/menu.rb', line 21

def get_porcentaje
	@porcentaje
end

#get_proteinasObject



30
31
32
# File 'lib/dieta/menu.rb', line 30

def get_proteinas
	@proteinas
end

#get_tituloObject



9
10
11
# File 'lib/dieta/menu.rb', line 9

def get_titulo
	@titulo
end

#get_vctObject



18
19
20
# File 'lib/dieta/menu.rb', line 18

def get_vct
	@vct
end

#getall_platosObject



15
16
17
# File 'lib/dieta/menu.rb', line 15

def getall_platos
	@platos
end

#to_sObject



24
25
26
27
28
29
# File 'lib/dieta/menu.rb', line 24

def to_s
	out = "#{@titulo.upcase} (#{@porcentaje}%)\n"
	out << @platos.map { |plato| "- #{plato}" }.join(",\n")
	out << "\nV.C.T. | % #{vct} kcal | #{proteinas}% - #{grasas}% - #{hidratos}%"
	out
end