Top Level Namespace

Defined Under Namespace

Modules: Nutrientes Classes: Antropometrico, DlinkedList, Individuo, Node, Nutricional_label, Pacientes

Instance Method Summary collapse

Instance Method Details

#ordenarArrayEach(lista_menus) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/Nutricional_label.rb', line 124

def ordenarArrayEach(lista_menus)
    arrayOrd = []
    lista_menus.each do |menus|
        if arrayOrd.empty?
            arrayOrd.push(menus)
        else
            indice = 0
            while indice < arrayOrd.length
                energia = menus.reduce(0) {|sum, val_ener| sum + val_ener.energetic_value_Kcal}
                energia_siguiente = arrayOrd[indice].reduce(0) {|sum, val_ener| sum + val_ener.energetic_value_Kcal}
                if energia <= energia_siguiente
                    arrayOrd.insert(indice, menus)
                    break
                elsif indice == arrayOrd.length-1
                    arrayOrd.insert(indice+1, menus)
                    break
                end
                indice+=1
            end
        end
    end
    return arrayOrd
    
end

#ordenarArrayFor(lista_menus) ⇒ Object



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/Nutricional_label.rb', line 149

def ordenarArrayFor(lista_menus)
    arrayOrd = []
    for menus in lista_menus
        if arrayOrd.empty?
            arrayOrd.push(menus)
        else
            indice = 0
            while indice < arrayOrd.length
                energia = menus.reduce(0) {|sum, val_ener| sum + val_ener.energetic_value_Kcal}
                energia_siguiente = arrayOrd[indice].reduce(0) {|sum, val_ener| sum + val_ener.energetic_value_Kcal}
                if energia <= energia_siguiente
                    arrayOrd.insert(indice, menus)
                    break
                elsif indice == arrayOrd.length-1
                    arrayOrd.insert(indice+1, menus)
                    break
                end
                indice+=1
            end
        end
    end
    return arrayOrd
    
end