Class: Aibc

Inherits:
Food show all
Defined in:
lib/alimento/alimento.rb

Overview

Note:

Clase Aibc heredada de Food para el calculo del aibc del alimento

Instance Attribute Summary

Attributes inherited from Food

#glucidos, #glucosa, #grasas, #n_grupo, #nombre, #proteinas, #valores

Instance Method Summary collapse

Methods inherited from Food

#<=>, #get_ve, #to_s

Constructor Details

#initialize(nombre, proteinas, glucidos, grasas, valores, glucosa) ⇒ Aibc

Note:

Inicializador de la clase heredada

Returns:

Inicializa nombre, proteinas, glucidos, grasas y valores



91
92
93
94
95
# File 'lib/alimento/alimento.rb', line 91

def initialize(nombre, proteinas, glucidos, grasas, valores, glucosa)
  super(nombre, proteinas, glucidos, grasas)
  @g = valores
  @glu = glucosa
end

Instance Method Details

#aibcObject

Note:

Metodo AIBC para el calculo del indice glucémico

Returns:

Valor del indice glucémico



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/alimento/alimento.rb', line 99

def aibc
    r = []
    (0..1).collect{ 
        |i| 
        s = []
        (1..24).collect{
            |index|
            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
        }
        r << s
    }

    aibc_alimento = []
    (0..1).collect{ |j|
        s=0
        (0..23).collect{
            |k|
            s = s + r[j][k]
        }
        aibc_alimento << s
    }
    
    r1 = []
    (0..1).collect{ 
        |i1| 
        s1 = []
        (1..24).collect{
            |index1|
            if @glu[i1][index1] < @glu[i1][0]
                s1 << 0.0
            else
                s1 << (((@glu[i1][index1] - @glu[i1][0]) + (@glu[i1][index1-1] - @glu[i1][0]))/2)*5
            end
        }
        r1 << s1
    }
    aibc_glucosa = []
    (0..1).collect{ 
        |j1|
        s1=0
        (0..23).collect{
            |k1|
            s1 = s1 + r1[j1][k1]
        }
        aibc_glucosa << s1
    }
    
    ig_alimento = (((aibc_alimento[0] /aibc_glucosa[0])*100) + (((aibc_alimento[1] /aibc_glucosa[1]))*100))/2
end