Class: Alimentos
- Inherits:
-
Object
- Object
- Alimentos
- Defined in:
- lib/alimento/alimentos.rb
Instance Attribute Summary collapse
-
#glucidos ⇒ Object
readonly
Returns the value of attribute glucidos.
-
#lipidos ⇒ Object
readonly
Returns the value of attribute lipidos.
-
#nombre ⇒ Object
readonly
Returns the value of attribute nombre.
-
#proteinas ⇒ Object
readonly
Returns the value of attribute proteinas.
Instance Method Summary collapse
- #==(otro) ⇒ Object
- #get_energetico ⇒ Object
- #get_glucidos ⇒ Object
- #get_lipidos ⇒ Object
- #get_nombre ⇒ Object
- #get_proteinas ⇒ Object
-
#initialize(nombre, proteinas, glucidos, lipidos) ⇒ Alimentos
constructor
A new instance of Alimentos.
- #to_s ⇒ Object
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
#glucidos ⇒ Object (readonly)
Returns the value of attribute glucidos.
2 3 4 |
# File 'lib/alimento/alimentos.rb', line 2 def glucidos @glucidos end |
#lipidos ⇒ Object (readonly)
Returns the value of attribute lipidos.
2 3 4 |
# File 'lib/alimento/alimentos.rb', line 2 def lipidos @lipidos end |
#nombre ⇒ Object (readonly)
Returns the value of attribute nombre.
2 3 4 |
# File 'lib/alimento/alimentos.rb', line 2 def nombre @nombre end |
#proteinas ⇒ Object (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_energetico ⇒ Object
23 24 25 26 |
# File 'lib/alimento/alimentos.rb', line 23 def get_energetico @aux = (@glucidos * 4) + (@lipidos * 9) + (@proteinas * 4) @aux end |
#get_glucidos ⇒ Object
15 16 17 |
# File 'lib/alimento/alimentos.rb', line 15 def get_glucidos @glucidos end |
#get_lipidos ⇒ Object
19 20 21 |
# File 'lib/alimento/alimentos.rb', line 19 def get_lipidos @lipidos end |
#get_nombre ⇒ Object
7 8 9 |
# File 'lib/alimento/alimentos.rb', line 7 def get_nombre @nombre end |
#get_proteinas ⇒ Object
11 12 13 |
# File 'lib/alimento/alimentos.rb', line 11 def get_proteinas @proteinas end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/alimento/alimentos.rb', line 32 def to_s "#{nombre}, #{proteinas}, #{glucidos}, #{lipidos}" end |