Class: Dieta

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

Overview

Implementar en este fichero la clase para crear objetos racionales

Direct Known Subclasses

GrpAlimento, GrpEdad

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(comida, porcentaje_comida, platos_comida, cantidad_platos, gr_platos, vct, porcentaje_proteinas, porcentaje_grasas, porcentaje_hidratos) ⇒ Dieta

FUINCION INITIALIZE



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

def initialize(comida,porcentaje_comida,platos_comida,cantidad_platos,gr_platos,vct,porcentaje_proteinas,porcentaje_grasas,porcentaje_hidratos)
    @comida=comida
    @porcentaje_comida=porcentaje_comida
    @platos_comida=platos_comida
    @cantidad_platos=cantidad_platos
    @gr_platos=gr_platos
    @vct=vct
    @porcentaje_proteinas=porcentaje_proteinas
    @porcentaje_grasas=porcentaje_grasas
    @porcentaje_hidratos=porcentaje_hidratos
end

Instance Attribute Details

#cantidad_platosObject

Returns the value of attribute cantidad_platos.



10
11
12
# File 'lib/dietas/dietas.rb', line 10

def cantidad_platos
  @cantidad_platos
end

#comidaObject

Returns the value of attribute comida.



10
11
12
# File 'lib/dietas/dietas.rb', line 10

def comida
  @comida
end

#gr_platosObject

Returns the value of attribute gr_platos.



10
11
12
# File 'lib/dietas/dietas.rb', line 10

def gr_platos
  @gr_platos
end

#platos_comidaObject

Returns the value of attribute platos_comida.



10
11
12
# File 'lib/dietas/dietas.rb', line 10

def platos_comida
  @platos_comida
end

#porcentaje_comidaObject

Returns the value of attribute porcentaje_comida.



10
11
12
# File 'lib/dietas/dietas.rb', line 10

def porcentaje_comida
  @porcentaje_comida
end

#porcentaje_grasasObject

Returns the value of attribute porcentaje_grasas.



10
11
12
# File 'lib/dietas/dietas.rb', line 10

def porcentaje_grasas
  @porcentaje_grasas
end

#porcentaje_hidratosObject

Returns the value of attribute porcentaje_hidratos.



10
11
12
# File 'lib/dietas/dietas.rb', line 10

def porcentaje_hidratos
  @porcentaje_hidratos
end

#porcentaje_proteinasObject

Returns the value of attribute porcentaje_proteinas.



10
11
12
# File 'lib/dietas/dietas.rb', line 10

def porcentaje_proteinas
  @porcentaje_proteinas
end

#vctObject

Returns the value of attribute vct.



10
11
12
# File 'lib/dietas/dietas.rb', line 10

def vct
  @vct
end

Instance Method Details

#<=>(other) ⇒ Object

Trabajamos con las calorias(vct)



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

def <=> other
    vct <=> other.vct
end

#get_cantidad_platosObject

GET CANTIDAD PALTOS



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

def get_cantidad_platos
    @cantidad_platos
end

#get_comidaObject

GET COMIDA



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

def get_comida
    @comida       
end

#get_gr_platosObject

GET GRAMOS PLATOS



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

def get_gr_platos
    @gr_platos
end

#get_platos_comidaObject

GET PLATOS COMIDA



42
43
44
# File 'lib/dietas/dietas.rb', line 42

def get_platos_comida
    @platos_comida
end

#get_porcentaje_comidaObject

GET PORCETAJE COMIDA



37
38
39
# File 'lib/dietas/dietas.rb', line 37

def get_porcentaje_comida
    @porcentaje_comida
end

#get_porcentaje_grasasObject

GET PORCENTAJE DE GRASAS



67
68
69
# File 'lib/dietas/dietas.rb', line 67

def get_porcentaje_grasas
    @porcentaje_grasas
end

#get_porcentaje_hidratosObject

GET PORCENTAJE DE HIDRATOS



72
73
74
# File 'lib/dietas/dietas.rb', line 72

def get_porcentaje_hidratos
    @porcentaje_hidratos
end

#get_porcentaje_proteinasObject

GET PORCENTAJE DE PROTEINAS



62
63
64
# File 'lib/dietas/dietas.rb', line 62

def get_porcentaje_proteinas
    @porcentaje_proteinas
end

#get_vctObject

GET CALORIAS



57
58
59
# File 'lib/dietas/dietas.rb', line 57

def get_vct
    @vct
end

#ordenacion_grObject

FUNCION SORT



77
78
79
# File 'lib/dietas/dietas.rb', line 77

def ordenacion_gr
    @gr_platos.sort
end

#to_sObject

TO_S



82
83
84
85
86
87
88
89
# File 'lib/dietas/dietas.rb', line 82

def to_s
    s="\n#{@comida} (#{@porcentaje_comida})\n"
    (0..@platos_comida.size-1).each do |i| 
        s<< "#{@platos_comida[i]}, #{@cantidad_platos[i]}, #{@gr_platos[i]}g.\n"
    end
    s<< "VCT | %\t#{@vct} kcal | #{@porcentaje_proteinas}% - #{@porcentaje_grasas}% - #{@porcentaje_hidratos}%\n"
    s
end