Class: Alimentos

Inherits:
Object
  • Object
show all
Defined in:
lib/alimento/alimentos.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nombre, proteinas, glucidos, lipidos) ⇒ Alimentos

Returns a new instance of Alimentos.



3
4
5
# File 'lib/alimento/alimentos.rb', line 3

def initialize nombre, proteinas, glucidos, lipidos
	@nombre, @proteinas, @glucidos, @lipidos = nombre, proteinas, glucidos, lipidos
end

Instance Attribute Details

#glucidosObject (readonly)

Returns the value of attribute glucidos.



2
3
4
# File 'lib/alimento/alimentos.rb', line 2

def glucidos
  @glucidos
end

#lipidosObject (readonly)

Returns the value of attribute lipidos.



2
3
4
# File 'lib/alimento/alimentos.rb', line 2

def lipidos
  @lipidos
end

#nombreObject (readonly)

Returns the value of attribute nombre.



2
3
4
# File 'lib/alimento/alimentos.rb', line 2

def nombre
  @nombre
end

#proteinasObject (readonly)

Returns the value of attribute proteinas.



2
3
4
# File 'lib/alimento/alimentos.rb', line 2

def proteinas
  @proteinas
end

Instance Method Details

#==(otro) ⇒ Object



28
29
30
# File 'lib/alimento/alimentos.rb', line 28

def == (otro)
	self.class == otro.class && @nombre == otro.nombre &&  @proteinas == otro.proteinas && @glucidos == otro.glucidos && @lipidos == otro.lipidos
end

#get_energeticoObject



23
24
25
26
# File 'lib/alimento/alimentos.rb', line 23

def get_energetico
	@aux = (@glucidos * 4) + (@lipidos * 9) + (@proteinas * 4)
	@aux
end

#get_glucidosObject



15
16
17
# File 'lib/alimento/alimentos.rb', line 15

def get_glucidos
	@glucidos
end

#get_lipidosObject



19
20
21
# File 'lib/alimento/alimentos.rb', line 19

def get_lipidos
	@lipidos
end

#get_nombreObject



7
8
9
# File 'lib/alimento/alimentos.rb', line 7

def get_nombre
	@nombre
end

#get_proteinasObject



11
12
13
# File 'lib/alimento/alimentos.rb', line 11

def get_proteinas
	@proteinas
end

#to_sObject



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

def to_s
	"#{nombre}, #{proteinas}, #{glucidos}, #{lipidos}"
end