Class: Menu

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

Overview

Clase que representa un menu

Direct Known Subclasses

Menu_edad, Menu_grupos

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(titulo, titulo_porcentaje, platos, porcion, gramos, vct, proteinas_porcetanje, grasas_porcetanje, hidratos_porcentaje) ⇒ Menu

Constructor de la clase



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/menus/menu.rb', line 13

def initialize(titulo, titulo_porcentaje, platos, porcion, gramos, vct, proteinas_porcetanje, grasas_porcetanje, hidratos_porcentaje)
    @titulo = titulo
    @titulo_porcentaje = titulo_porcentaje
    @platos = platos
    @porcion = porcion
    @gramos = gramos
    @vct = vct
    @proteinas_porcetanje = proteinas_porcetanje
    @grasas_porcetanje = grasas_porcetanje
    @hidratos_porcentaje = hidratos_porcentaje
end

Instance Attribute Details

#gramosObject

Returns the value of attribute gramos.



4
5
6
# File 'lib/menus/menu.rb', line 4

def gramos
  @gramos
end

#grasas_porcetanjeObject

Returns the value of attribute grasas_porcetanje.



4
5
6
# File 'lib/menus/menu.rb', line 4

def grasas_porcetanje
  @grasas_porcetanje
end

#hidratos_porcentajeObject

Returns the value of attribute hidratos_porcentaje.



4
5
6
# File 'lib/menus/menu.rb', line 4

def hidratos_porcentaje
  @hidratos_porcentaje
end

#platosObject

Returns the value of attribute platos.



4
5
6
# File 'lib/menus/menu.rb', line 4

def platos
  @platos
end

#porcionObject

Returns the value of attribute porcion.



4
5
6
# File 'lib/menus/menu.rb', line 4

def porcion
  @porcion
end

#proteinas_porcetanjeObject

Returns the value of attribute proteinas_porcetanje.



4
5
6
# File 'lib/menus/menu.rb', line 4

def proteinas_porcetanje
  @proteinas_porcetanje
end

#tituloObject

Returns the value of attribute titulo.



4
5
6
# File 'lib/menus/menu.rb', line 4

def titulo
  @titulo
end

#titulo_porcentajeObject

Returns the value of attribute titulo_porcentaje.



4
5
6
# File 'lib/menus/menu.rb', line 4

def titulo_porcentaje
  @titulo_porcentaje
end

#vctObject

Returns the value of attribute vct.



4
5
6
# File 'lib/menus/menu.rb', line 4

def vct
  @vct
end

Instance Method Details

#<=>(other) ⇒ Object



8
9
10
# File 'lib/menus/menu.rb', line 8

def <=>(other)
    @vct <=> other.vct
end

#get_descripcionObject

Obtener descripcion



26
27
28
# File 'lib/menus/menu.rb', line 26

def get_descripcion
    @descripcion
end

#get_grasas_porcentajeObject



60
61
62
# File 'lib/menus/menu.rb', line 60

def get_grasas_porcentaje()
    @grasas_porcetanje
end

#get_hidratos_porcentajeObject



64
65
66
# File 'lib/menus/menu.rb', line 64

def get_hidratos_porcentaje()
    @hidratos_porcentaje
end

#get_plato(i) ⇒ Object

Obtener un plato



41
42
43
# File 'lib/menus/menu.rb', line 41

def get_plato(i)
    @platos[i]
end

#get_platosObject

Obtener la lista de platos



47
48
49
# File 'lib/menus/menu.rb', line 47

def get_platos()
    @platos
end

#get_proteinas_porcetanjeObject



56
57
58
# File 'lib/menus/menu.rb', line 56

def get_proteinas_porcetanje()
    @proteinas_porcetanje
end

#get_tituloObject

Obtener titulo



31
32
33
# File 'lib/menus/menu.rb', line 31

def get_titulo
    @titulo
end

#get_titulo_porcentajeObject

Obtener porcentaje



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

def get_titulo_porcentaje
    @titulo_porcentaje
end

#get_vctObject

Obtener el valor calorico total



52
53
54
# File 'lib/menus/menu.rb', line 52

def get_vct()
    @vct
end

#to_sObject



68
69
70
71
72
73
74
75
76
77
# File 'lib/menus/menu.rb', line 68

def to_s
    buffer = "#{@titulo} #{@titulo_porcentaje}\n"
    i = 0;
    while i < @platos.size()
        buffer << "#{platos[i]}, #{porcion[i]}, #{gramos[i]} g\n"
        i = i + 1
    end
    buffer << "V.C.T. | % #{@vct} kcal | #{@proteinas_porcetanje}% - #{@hidratos_porcentaje}% - #{@grasas_porcetanje}%"
    return buffer
end