Class: Experimento

Inherits:
Object
  • Object
show all
Defined in:
lib/nutrientes/glucosa.rb

Overview

Class Experimento Calculates the glucemic value of a food

Instance Method Summary collapse

Constructor Details

#initialize(alimento, medidas, glucosa) ⇒ Experimento

Initialization of the object given its attributes

Parameters:

  • alimento (Object)

    Test target

  • medidas (Array)

    Measures from a subject

  • glucosa (Array)

    Measures of glucose



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

Parameters:

  • i (FixNum)

    Index of the current element

Returns:

  • (FixNum)

    AIBC



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_IGFixNum

Calculates the Glucemic index

Returns:

  • (FixNum)

    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