Class: Menu

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

Direct Known Subclasses

Menu_Saludable

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

Returns a new instance of Menu.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/menus/menu.rb', line 5

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.



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

def gramos
  @gramos
end

#grasas_porcetanjeObject

Returns the value of attribute grasas_porcetanje.



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

def grasas_porcetanje
  @grasas_porcetanje
end

#hidratos_porcentajeObject

Returns the value of attribute hidratos_porcentaje.



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

def hidratos_porcentaje
  @hidratos_porcentaje
end

#platosObject

Returns the value of attribute platos.



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

def platos
  @platos
end

#porcionObject

Returns the value of attribute porcion.



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

def porcion
  @porcion
end

#proteinas_porcetanjeObject

Returns the value of attribute proteinas_porcetanje.



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

def proteinas_porcetanje
  @proteinas_porcetanje
end

#tituloObject

Returns the value of attribute titulo.



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

def titulo
  @titulo
end

#titulo_porcentajeObject

Returns the value of attribute titulo_porcentaje.



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

def titulo_porcentaje
  @titulo_porcentaje
end

#vctObject

Returns the value of attribute vct.



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

def vct
  @vct
end

Instance Method Details

#<=>(value) ⇒ Object

— Definición del Método Mixins para las comparaciones del módulo Comparable



19
20
21
22
# File 'lib/menus/menu.rb', line 19

def <=>(value)
  return nil unless value.instance_of? Menu
  @proteinas_porcetanje <=> value.proteinas_porcetanje
end

#get_descripcionObject



24
25
26
# File 'lib/menus/menu.rb', line 24

def get_descripcion
    @descripcion
end

#get_grasas_porcentajeObject



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

def get_grasas_porcentaje()
    @grasas_porcetanje
end

#get_hidratos_porcentajeObject



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

def get_hidratos_porcentaje()
    @hidratos_porcentaje
end

#get_plato(i) ⇒ Object



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

def get_plato(i)
    @platos[i]
end

#get_platosObject



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

def get_platos()
    @platos
end

#get_proteinas_porcetanjeObject



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

def get_proteinas_porcetanje()
    @proteinas_porcetanje
end

#get_tituloObject



28
29
30
# File 'lib/menus/menu.rb', line 28

def get_titulo
    @titulo
end

#get_titulo_porcentajeObject



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

def get_titulo_porcentaje
    @titulo_porcentaje
end

#get_vctObject



44
45
46
# File 'lib/menus/menu.rb', line 44

def get_vct()
    @vct
end

#to_sObject



60
61
62
63
64
65
66
67
68
69
# File 'lib/menus/menu.rb', line 60

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}%\n"
    return buffer
end