Class: Etiqueta

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/alu0100987522/version.rb,
lib/alu0100987522/etiqueta.rb

Constant Summary collapse

VERSION =
"0.1.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#azucarObject (readonly)

Returns the value of attribute azucar.



5
6
7
# File 'lib/alu0100987522/etiqueta.rb', line 5

def azucar
  @azucar
end

#carbhObject (readonly)

Returns the value of attribute carbh.



5
6
7
# File 'lib/alu0100987522/etiqueta.rb', line 5

def carbh
  @carbh
end

#grasasObject (readonly)

Returns the value of attribute grasas.



5
6
7
# File 'lib/alu0100987522/etiqueta.rb', line 5

def grasas
  @grasas
end

#gsatObject (readonly)

Returns the value of attribute gsat.



5
6
7
# File 'lib/alu0100987522/etiqueta.rb', line 5

def gsat
  @gsat
end

#nombreObject (readonly)

Returns the value of attribute nombre.



5
6
7
# File 'lib/alu0100987522/etiqueta.rb', line 5

def nombre
  @nombre
end

#proteinObject (readonly)

Returns the value of attribute protein.



5
6
7
# File 'lib/alu0100987522/etiqueta.rb', line 5

def protein
  @protein
end

#salObject (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_sObject



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_energeticoObject



20
21
22
# File 'lib/alu0100987522/etiqueta.rb', line 20

def val_energetico
  (grasas*9+carbh*4+protein*4)
end