Class: Etiqueta
- Inherits:
-
Object
- Object
- Etiqueta
- Includes:
- Comparable
- Defined in:
- lib/alu0100987522/version.rb,
lib/alu0100987522/etiqueta.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#azucar ⇒ Object
readonly
Returns the value of attribute azucar.
-
#carbh ⇒ Object
readonly
Returns the value of attribute carbh.
-
#grasas ⇒ Object
readonly
Returns the value of attribute grasas.
-
#gsat ⇒ Object
readonly
Returns the value of attribute gsat.
-
#nombre ⇒ Object
readonly
Returns the value of attribute nombre.
-
#protein ⇒ Object
readonly
Returns the value of attribute protein.
-
#sal ⇒ Object
readonly
Returns the value of attribute sal.
Instance Method Summary collapse
- #<=>(another) ⇒ Object
-
#initialize(nombre, grasas, gsat, carbh, azucar, protein, sal) ⇒ Etiqueta
constructor
A new instance of Etiqueta.
- #to_s ⇒ Object
- #val_energetico ⇒ Object
Constructor Details
#initialize(nombre, grasas, gsat, carbh, azucar, protein, sal) ⇒ Etiqueta
Returns a new instance of Etiqueta.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/alu0100987522/etiqueta.rb', line 8 def initialize(nombre, grasas, gsat, carbh, azucar, protein, sal) @nombre = nombre @grasas = grasas @gsat = gsat @carbh = carbh @azucar = azucar @protein = protein @sal = sal end |
Instance Attribute Details
#azucar ⇒ Object (readonly)
Returns the value of attribute azucar.
5 6 7 |
# File 'lib/alu0100987522/etiqueta.rb', line 5 def azucar @azucar end |
#carbh ⇒ Object (readonly)
Returns the value of attribute carbh.
5 6 7 |
# File 'lib/alu0100987522/etiqueta.rb', line 5 def carbh @carbh end |
#grasas ⇒ Object (readonly)
Returns the value of attribute grasas.
5 6 7 |
# File 'lib/alu0100987522/etiqueta.rb', line 5 def grasas @grasas end |
#gsat ⇒ Object (readonly)
Returns the value of attribute gsat.
5 6 7 |
# File 'lib/alu0100987522/etiqueta.rb', line 5 def gsat @gsat end |
#nombre ⇒ Object (readonly)
Returns the value of attribute nombre.
5 6 7 |
# File 'lib/alu0100987522/etiqueta.rb', line 5 def nombre @nombre end |
#protein ⇒ Object (readonly)
Returns the value of attribute protein.
5 6 7 |
# File 'lib/alu0100987522/etiqueta.rb', line 5 def protein @protein end |
#sal ⇒ Object (readonly)
Returns the value of attribute sal.
5 6 7 |
# File 'lib/alu0100987522/etiqueta.rb', line 5 def sal @sal end |
Instance Method Details
#<=>(another) ⇒ Object
28 29 30 |
# File 'lib/alu0100987522/etiqueta.rb', line 28 def <=>(another) val_energetico <=> another.val_energetico end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/alu0100987522/etiqueta.rb', line 24 def to_s return %Q"#{@nombre} --- Grasas: #{@grasas} ; Saturadas: #{@gsat} -- Hidratos de Carbono: #{@carbh} -- Azucar: #{@azucar} -- Proteínas: #{@protein} -- Sal: #{@sal}. " end |
#val_energetico ⇒ Object
20 21 22 |
# File 'lib/alu0100987522/etiqueta.rb', line 20 def val_energetico (grasas*9+carbh*4+protein*4) end |