Class: Experimento
- Inherits:
-
Object
- Object
- Experimento
- Defined in:
- lib/nutrientes/glucosa.rb
Overview
Class Experimento Calculates the glucemic value of a food
Instance Method Summary collapse
-
#get_AIBC(i) ⇒ FixNum
Calculates the AIBC recursively.
-
#get_IG ⇒ FixNum
Calculates the Glucemic index.
-
#initialize(alimento, medidas, glucosa) ⇒ Experimento
constructor
Initialization of the object given its attributes.
Constructor Details
#initialize(alimento, medidas, glucosa) ⇒ Experimento
Initialization of the object given its attributes
17 18 19 20 21 |
# File 'lib/nutrientes/glucosa.rb', line 17 def initialize(alimento, medidas, glucosa) @alimento = alimento @medidas = medidas @glucosa = glucosa end |
Instance Method Details
#get_AIBC(i) ⇒ FixNum
Calculates the AIBC recursively
26 27 28 29 30 31 32 33 |
# 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 ⇒ FixNum
Calculates the Glucemic index
37 38 39 |
# File 'lib/nutrientes/glucosa.rb', line 37 def get_IG() return (get_AIBC(1) / Experimento.new(nil, @glucosa, @glucosa).get_AIBC(1)) * 100 end |