Class: Dieta_t

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

Overview

Clase dieta padre

Direct Known Subclasses

DietaEdad_t, DietaTipo_t

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(titulo, porcdiario, descripcion, porciones, ingengr, conjplatos, vct, porcproteinas, porcgrasas, porchidratos) ⇒ Dieta_t

Constructor de la clase Dieta_t



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

def initialize(titulo, porcdiario, descripcion, porciones, ingengr, conjplatos, vct, porcproteinas, porcgrasas, porchidratos)
  @titulo = titulo
  @porcdiario = porcdiario
  @descripcion = descripcion
  @porciones = porciones
  @ingengr = ingengr
  @conjplatos = conjplatos
  @vct = vct
  @porcproteinas = porcproteinas
  @porcgrasas = porcgrasas
  @porchidratos = porchidratos
end

Instance Attribute Details

#conjplatosObject

Returns the value of attribute conjplatos.



8
9
10
# File 'lib/prct06/dieta.rb', line 8

def conjplatos
  @conjplatos
end

#descripcionObject

Returns the value of attribute descripcion.



8
9
10
# File 'lib/prct06/dieta.rb', line 8

def descripcion
  @descripcion
end

#ingengrObject

Returns the value of attribute ingengr.



8
9
10
# File 'lib/prct06/dieta.rb', line 8

def ingengr
  @ingengr
end

#porcdiarioObject

Returns the value of attribute porcdiario.



8
9
10
# File 'lib/prct06/dieta.rb', line 8

def porcdiario
  @porcdiario
end

#porcgrasasObject

Returns the value of attribute porcgrasas.



8
9
10
# File 'lib/prct06/dieta.rb', line 8

def porcgrasas
  @porcgrasas
end

#porchidratosObject

Returns the value of attribute porchidratos.



8
9
10
# File 'lib/prct06/dieta.rb', line 8

def porchidratos
  @porchidratos
end

#porcionesObject

Returns the value of attribute porciones.



8
9
10
# File 'lib/prct06/dieta.rb', line 8

def porciones
  @porciones
end

#porcproteinasObject

Returns the value of attribute porcproteinas.



8
9
10
# File 'lib/prct06/dieta.rb', line 8

def porcproteinas
  @porcproteinas
end

#tituloObject

Returns the value of attribute titulo.



8
9
10
# File 'lib/prct06/dieta.rb', line 8

def titulo
  @titulo
end

#vctObject

Returns the value of attribute vct.



8
9
10
# File 'lib/prct06/dieta.rb', line 8

def vct
  @vct
end

Instance Method Details

#<=>(other) ⇒ Object

Permite comparar dietas



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

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

#to_sObject

Muestra el contenido de la clase Dieta_t



26
27
28
29
30
31
32
33
# File 'lib/prct06/dieta.rb', line 26

def to_s
  mostrar = ""
  mostrar << "\n\n#{@titulo} (#{@porcdiario} %)\n"
  for i in 0..(@conjplatos-1)
    mostrar << "- #{@descripcion[i]}, #{@porciones[i]}, #{@ingengr[i]}\n"
  end
  mostrar << "V.C.T | % #{@vct} kcal | #{@porcproteinas}% - #{@porcgrasas}% - #{@porchidratos}%\n\n"
end