class Alimentos

Public Class Methods

new(nombre, proteinas, glucidos, lipidos) click to toggle source
# File lib/prct06/alimentos.rb, line 7
def initialize(nombre, proteinas, glucidos,  lipidos)
  @nombre = nombre
  @proteinas = proteinas
  @glucidos = glucidos
  @lipidos = lipidos
end

Public Instance Methods

<=>(anOther) click to toggle source
# File lib/prct06/alimentos.rb, line 3
def <=>(anOther)
  energy <=> anOther.energy
end
energy() click to toggle source
# File lib/prct06/alimentos.rb, line 28
def energy
  @proteinas * 4 + @glucidos * 4 + @lipidos *9
end
format() click to toggle source
# File lib/prct06/alimentos.rb, line 25
def format
  "(Alimento: #{@nombre}, proteinas: #{@proteinas}, glucidos: #{@glucidos}, lipidos: #{@lipidos})"
end
glucidos() click to toggle source
# File lib/prct06/alimentos.rb, line 19
def glucidos
  @glucidos
end
lipidos() click to toggle source
# File lib/prct06/alimentos.rb, line 22
def lipidos
  @lipidos
end
name() click to toggle source
# File lib/prct06/alimentos.rb, line 13
def name
  @nombre
end
proteinas() click to toggle source
# File lib/prct06/alimentos.rb, line 16
def proteinas
  @proteinas
end