Class: Dieta

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

Direct Known Subclasses

DietaDSL, GrupoAlimento, GrupoEdad

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(titulo, porcentaje, platos, porcion, gramos, kcal, pgh) ⇒ Dieta

Returns a new instance of Dieta.



5
6
7
8
9
10
11
12
13
# File 'lib/MenuDieta/dieta.rb', line 5

def initialize(titulo, porcentaje, platos, porcion, gramos, kcal, pgh)
    @titulo = titulo
    @porcentaje = porcentaje
    @platos = platos
    @porcion = porcion
    @gramos = gramos
    @kcal = kcal
    @pgh = pgh
end

Instance Attribute Details

#gramosObject

Returns the value of attribute gramos.



3
4
5
# File 'lib/MenuDieta/dieta.rb', line 3

def gramos
  @gramos
end

#kcalObject

Returns the value of attribute kcal.



3
4
5
# File 'lib/MenuDieta/dieta.rb', line 3

def kcal
  @kcal
end

#pghObject

Returns the value of attribute pgh.



3
4
5
# File 'lib/MenuDieta/dieta.rb', line 3

def pgh
  @pgh
end

#platosObject

Returns the value of attribute platos.



3
4
5
# File 'lib/MenuDieta/dieta.rb', line 3

def platos
  @platos
end

#porcentajeObject

Returns the value of attribute porcentaje.



3
4
5
# File 'lib/MenuDieta/dieta.rb', line 3

def porcentaje
  @porcentaje
end

#porcionObject

Returns the value of attribute porcion.



3
4
5
# File 'lib/MenuDieta/dieta.rb', line 3

def porcion
  @porcion
end

#tituloObject

Returns the value of attribute titulo.



3
4
5
# File 'lib/MenuDieta/dieta.rb', line 3

def titulo
  @titulo
end

Instance Method Details

#<=>(anOther) ⇒ Object



34
35
36
# File 'lib/MenuDieta/dieta.rb', line 34

def <=> (anOther)
    self.kcal <=> anOther.kcal 
end

#==(anOther) ⇒ Object



38
39
40
# File 'lib/MenuDieta/dieta.rb', line 38

def == (anOther)
    return (kcal==anOther.kcal) && (pgh == anOther.pgh)
end

#to_sObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/MenuDieta/dieta.rb', line 15

def to_s
    aux = "#{titulo} (#{porcentaje})\n"
    i = 0
    while i < @platos.size
        aux = aux + "- #{@platos[i]}, #{@porcion[i]}, #{@gramos[i]} g\n"
        i = i + 1
    end
    aux = aux + "V.C.T. | % #{kcal} Kcal |"
    i = 0
    while i < @pgh.size
        aux = aux + " #{@pgh[i]}%"
        if(i < @pgh.size-1)
            aux = aux + " -"
        end
        i = i + 1
    end
    return aux
end