class Alimentos
Attributes
glucidos[R]
lipidos[R]
nombre[R]
proteinas[R]
Public Class Methods
new(nombre,proteinas,glucidos,lipidos)
click to toggle source
# File lib/alimento/alimento.rb, line 22 def initialize(nombre,proteinas,glucidos,lipidos) @nombre,@proteinas,@glucidos,@lipidos= nombre,proteinas,glucidos,lipidos end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/alimento/alimento.rb, line 28 def <=>(other) nombre.size <=> other.nombre.size ve <=> other.ve end
aibc(g)
click to toggle source
# File lib/alimento/alimento.rb, line 38 def aibc(g) i = 0 r = [] while i < g.size index = 1 s = [] while index < g[i].size if g[i][index] < g[i][0] s << 0.0 else s << (((g[i][index] - g[i][0]) + (g[i][index-1] - g[i][0]))/2)*5 end index = index + 1 end r << s i = i + 1 end suma = [] j = 0 while j < g.size k = 0 s = 0 while k < r[j].size s = s + r[j][k] k = k + 1 end suma << s j = j + 1 end suma end
to_s()
click to toggle source
# File lib/alimento/alimento.rb, line 70 def to_s "Alimento: #{@nombre}\n------------------------------\nProteínas:\s#{@proteinas}g\nGlúcidos:\s#{@glucidos}g\nLípidos:\s#{@lipidos}g" end
ve()
click to toggle source
# File lib/alimento/alimento.rb, line 33 def ve (@proteinas*4+@glucidos*4+@lipidos*9).round(3) end