class Experimento
Class Experimento
Calculates the glucemic value of a food
Public Class Methods
new(alimento, medidas, glucosa)
click to toggle source
Initialization of the object given its attributes @param alimento [Object] Test target @param medidas [Array] Measures from a subject @param glucosa [Array] Measures of glucose
# File lib/nutrientes/glucosa.rb, line 17 def initialize(alimento, medidas, glucosa) @alimento = alimento @medidas = medidas @glucosa = glucosa end
Public Instance Methods
get_AIBC(i)
click to toggle source
Calculates the AIBC recursively @param i [FixNum] Index of the current element @return [FixNum] AIBC
# File lib/nutrientes/glucosa.rb, line 26 def get_AIBC(i) @@tam = @medidas.length if i >= @@tam return 0 else return (((@medidas[i] - @medidas[0]) + (@medidas[i - 1] - @medidas[0])) / 24) + get_AIBC(i + 1) end end
get_IG()
click to toggle source
Calculates the Glucemic index @return [FixNum] Glucemic index
# File lib/nutrientes/glucosa.rb, line 37 def get_IG() return (get_AIBC(1) / Experimento.new(nil, @glucosa, @glucosa).get_AIBC(1)) * 100 end