Alimento 0.1.0 → 30.30.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Alimento-0.1.0.gem +0 -0
- data/Alimento.gemspec +2 -6
- data/Gemfile +2 -0
- data/Rakefile +5 -62
- data/lib/Alimento.rb +2 -9
- data/lib/Alimento/alimentos.rb +9 -136
- data/lib/Alimento/version.rb +1 -1
- metadata +5 -84
- data/.coveralls.yml +0 -6
- data/.rake_tasks~ +0 -8
- data/Guardfile +0 -82
- data/docs/Alimentos.html +0 -1854
- data/docs/ListaDoble.html +0 -1236
- data/docs/Nodo.html +0 -398
- data/docs/_index.html +0 -133
- data/docs/class_list.html +0 -51
- data/docs/css/common.css +0 -1
- data/docs/css/full_list.css +0 -58
- data/docs/css/style.css +0 -492
- data/docs/file.README.html +0 -117
- data/docs/file_list.html +0 -56
- data/docs/frames.html +0 -17
- data/docs/index.html +0 -117
- data/docs/js/app.js +0 -248
- data/docs/js/full_list.js +0 -216
- data/docs/js/jquery.js +0 -4
- data/docs/method_list.html +0 -299
- data/docs/top-level-namespace.html +0 -110
- data/lib/Alimento/glucemico.rb +0 -333
- data/lib/Alimento/lista_doble.rb +0 -155
- data/lib/Alimento/ordenacion.rb +0 -321
- data/lib/Alimento/tipo_alimento.rb +0 -29
data/lib/Alimento/ordenacion.rb
DELETED
@@ -1,321 +0,0 @@
|
|
1
|
-
require "Alimento/alimentos.rb"
|
2
|
-
require 'benchmark'
|
3
|
-
include Benchmark
|
4
|
-
|
5
|
-
|
6
|
-
class Array
|
7
|
-
NUM_ALIMENTOS = 5
|
8
|
-
def burbuja_for (array)
|
9
|
-
#n=a.length
|
10
|
-
a = Array.new
|
11
|
-
a = array
|
12
|
-
for i in 0...a.length-1
|
13
|
-
for j in 0...a.length-i-1
|
14
|
-
if a[j]>a[j+1]
|
15
|
-
temp=a[j]
|
16
|
-
a[j]=a[j+1]
|
17
|
-
a[j+1]=temp
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
return a
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
def burbuja_each (a)
|
26
|
-
tmp = 0
|
27
|
-
array = Array.new
|
28
|
-
array = a
|
29
|
-
# nuevo = new.Array
|
30
|
-
#array = array2.split(" ")
|
31
|
-
(0..array.length-1).each do |i|
|
32
|
-
(0..array.length-2).each do |j|
|
33
|
-
if(array[j] > array[j+1])
|
34
|
-
tmp = array[j]
|
35
|
-
array[j] = array[j+1]
|
36
|
-
array[j+1] = tmp
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
return array;
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
class Ordenacion
|
46
|
-
|
47
|
-
NUM_ALIMENTOS = 5
|
48
|
-
|
49
|
-
def self.description
|
50
|
-
"clase que muestra informacion de nutrientes de un Alimento"
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
attr_accessor :huevo_frito, :leche_de_vaca ,:yogurt ,:cerdo ,:ternera, :pollo ,:bacalao, :atun ,:salmon, :aceita_de_oliva ,:chocolate ,:azucar ,:arroz ,:lentejas, :papas, :tomate, :cebolla ,:manzana, :platano
|
57
|
-
attr_accessor :alimentos
|
58
|
-
def initialize ()
|
59
|
-
|
60
|
-
@huevo_frito= ['Huevo',14.1,0.0,19.5]
|
61
|
-
@leche_de_vaca = ['Leche de vaca',3.3,4.8,3.2]
|
62
|
-
@yogurt = ['Yogurt',3.8,4.9,3.8]
|
63
|
-
@cerdo = ['Cerdo',21.5,0.0,6.3]
|
64
|
-
@ternera = ['Ternera',21.1,0.0,3.1]
|
65
|
-
@pollo= ['Pollo',20.6,0.0,5.6]
|
66
|
-
@bacalao = ['Bacalao',17.7,0.0,0.4]
|
67
|
-
@atun = ['Atun',21.5,0.0,15.5]
|
68
|
-
@salmon = ['Salmon',19.9,0.0,13.6]
|
69
|
-
@aceita_de_oliva = ['Aceite de oliva',0.0,0.2,99.6]
|
70
|
-
@chocolate = ['Chocolate',5.3,47.0,30.0]
|
71
|
-
@azucar = ['Azucar',0.0,99.8,0.0]
|
72
|
-
@arroz = ['Arroz',6.8,77.7,0.6]
|
73
|
-
@lentejas = ['Lentejas',23.5,52.0,1.4]
|
74
|
-
@papas = ['Papas',2.0,15.4,0.1]
|
75
|
-
@tomate = ['Tomate',1.0,3.5,0.2]
|
76
|
-
@cebolla = ['Cebolla',1.3,5.8,0.3]
|
77
|
-
@manzana = ['Manzana',0.3,12.4,0.4]
|
78
|
-
@platano = ['Platano',1.2,21.4,0.2]
|
79
|
-
|
80
|
-
@alimentos = [@huevo_frito,@leche_de_vaca,@yogurt,@cerdo,@ternera,@pollo,@bacalao,@atun,@salmon,@aceita_de_oliva,@chocolate,@azucar,@arroz,@lentejas,@papas,@tomate,@cebolla,@manzana,@platano]
|
81
|
-
@alimentor = [@huevo_frito,@leche_de_vaca,@yogurt,@cerdo,@ternera,@pollo,@bacalao]
|
82
|
-
@prueba_extrema = [999999,88888888,777777777,6666666,5555555,4444444,33333,22222,11111]
|
83
|
-
@prueba_extrema2 = [9,8,7,6,5,4,3,2,1]
|
84
|
-
end
|
85
|
-
|
86
|
-
def calculo_calorias (alimento,cantidad)
|
87
|
-
|
88
|
-
#a = /\p{N}/.match (cantidad)
|
89
|
-
number = cantidad.match(/\d+/)[0]
|
90
|
-
#puts (number)
|
91
|
-
|
92
|
-
result = []
|
93
|
-
|
94
|
-
#@alimentor.each_with_index do |alimento,i|
|
95
|
-
if (number.to_f > 3.0)
|
96
|
-
result = (alimento[1]*4.0) + (alimento[2]*4.0) + (alimento[3]*9.0)
|
97
|
-
else
|
98
|
-
result = (alimento[1]*4.0*number.to_f) + (alimento[2]*4.0*number.to_f) + (alimento[3]*9.0*number.to_f)
|
99
|
-
#result.to_s
|
100
|
-
end
|
101
|
-
#end
|
102
|
-
return (result)
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
def to_s
|
110
|
-
|
111
|
-
i = 0
|
112
|
-
j = 0
|
113
|
-
|
114
|
-
r = []
|
115
|
-
#each_byte
|
116
|
-
result = ""
|
117
|
-
#a = [[11111,222222,33333333],[4444,5555,6666],[7777,88888,99999]]
|
118
|
-
for i in 0...@alimentos.length-1
|
119
|
-
for j in 0...@alimentos.length-1
|
120
|
-
|
121
|
-
result << "#{@alimentos[i][j]}"
|
122
|
-
result << " "
|
123
|
-
|
124
|
-
|
125
|
-
end
|
126
|
-
result << "\n"
|
127
|
-
end
|
128
|
-
return (result)
|
129
|
-
|
130
|
-
end
|
131
|
-
|
132
|
-
end #class
|
133
|
-
#@a = []
|
134
|
-
|
135
|
-
#################################################3
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
#class Plato < Ordenacion
|
142
|
-
class Plato
|
143
|
-
attr_accessor :name, :vegetales, :frutas, :granos_integrales, :proteinas_saludables, :aceites, :aguas, :compo_nutri
|
144
|
-
attr_accessor :agua, :aceite, :proteina, :cereal, :vegetal, :fruta
|
145
|
-
attr_accessor :busqueda, :to_s
|
146
|
-
def initialize(name, &block)
|
147
|
-
#super (huevo_frito)
|
148
|
-
@name = name
|
149
|
-
@vegetales = []
|
150
|
-
@frutas = []
|
151
|
-
@granos_integrales = []
|
152
|
-
@proteinas_saludables = []
|
153
|
-
@aceites = []
|
154
|
-
@aguas = []
|
155
|
-
@compo_nutri = []
|
156
|
-
@sumatorio = 0.0
|
157
|
-
|
158
|
-
|
159
|
-
# super(huevo_frito,leche_de_vaca,yogurt,cerdo,ternera,pollo,bacalao,atun,salmon,aceita_de_oliva,chocolate,azucar,arroz,lentejas,papas,tomate,cebolla,manzana,platano)
|
160
|
-
#super(alimentos)
|
161
|
-
|
162
|
-
if block_given?
|
163
|
-
if block.arity == 1
|
164
|
-
yield self
|
165
|
-
else
|
166
|
-
instance_eval(&block)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
###################################################################################
|
172
|
-
#@alimentos es de la clase ordenacion
|
173
|
-
#elemento = alimento
|
174
|
-
#arreglar
|
175
|
-
|
176
|
-
def busqueda(ingrediente,cantidad)
|
177
|
-
@datos = Ordenacion.new()
|
178
|
-
|
179
|
-
final = ""
|
180
|
-
retorna = ""
|
181
|
-
salida = ""
|
182
|
-
@datos.alimentos.each_with_index do |alimento, index|
|
183
|
-
|
184
|
-
if (ingrediente == alimento[0])
|
185
|
-
#puts (alimento[0])
|
186
|
-
result = @datos.calculo_calorias(alimento,cantidad)
|
187
|
-
@sumatorio += result
|
188
|
-
#puts (@sumatorio)
|
189
|
-
a = alimento[0].to_s
|
190
|
-
b = alimento[1].to_s
|
191
|
-
c = alimento[2].to_s
|
192
|
-
d = alimento[3].to_s
|
193
|
-
e = result.to_s
|
194
|
-
retorna <<" "<<a.ljust(15) <<" "<< b.ljust(8) <<" "<< c.ljust(9) <<" "<< d.ljust(5) <<" "<< e.ljust(25) << " "
|
195
|
-
end
|
196
|
-
salida = retorna
|
197
|
-
end
|
198
|
-
final = salida
|
199
|
-
final
|
200
|
-
|
201
|
-
end
|
202
|
-
|
203
|
-
def to_s
|
204
|
-
output = @name
|
205
|
-
output << "\n#{'=' * @name.size}\n"
|
206
|
-
output << "Composicion Nutricional:\n"
|
207
|
-
output << " glúcidos proteı́nas lı́pidos valor energético\n"
|
208
|
-
|
209
|
-
a = []
|
210
|
-
b = []
|
211
|
-
#p (@compo_nutri)
|
212
|
-
@compo_nutri.each_with_index do |ingrediente,index|
|
213
|
-
|
214
|
-
|
215
|
-
output << busqueda(ingrediente[0],ingrediente[1]).to_s
|
216
|
-
#p (ingrediente[0])
|
217
|
-
#p (ingrediente[1])
|
218
|
-
output << "\n"
|
219
|
-
|
220
|
-
end
|
221
|
-
output << "Valor energético total " << @sumatorio.to_s
|
222
|
-
|
223
|
-
output
|
224
|
-
end
|
225
|
-
|
226
|
-
################################################################################
|
227
|
-
|
228
|
-
def vegetal(text, options = {})
|
229
|
-
alimento = [text]
|
230
|
-
alimento <<"(#{options[:porcion]})" if options[:porcion]
|
231
|
-
@compo_nutri << alimento
|
232
|
-
end
|
233
|
-
|
234
|
-
def fruta(text, options = {})
|
235
|
-
alimento = [text]
|
236
|
-
alimento <<"(#{options[:gramos]})" if options[:gramos]
|
237
|
-
@compo_nutri << alimento
|
238
|
-
end
|
239
|
-
|
240
|
-
def cereal(text, options = {})
|
241
|
-
alimento = [text]
|
242
|
-
alimento <<"(#{options[:porcion]})" if options[:porcion]
|
243
|
-
@compo_nutri << alimento
|
244
|
-
end
|
245
|
-
|
246
|
-
def proteina(text, options = {})
|
247
|
-
alimento = [text]
|
248
|
-
alimento <<"(#{options[:porcion]})" if options[:porcion]
|
249
|
-
@compo_nutri << alimento
|
250
|
-
end
|
251
|
-
|
252
|
-
def aceite(text, options = {})
|
253
|
-
alimento = [text]
|
254
|
-
alimento <<"(#{options[:porcion]})" if options[:porcion]
|
255
|
-
@compo_nutri << alimento
|
256
|
-
end
|
257
|
-
|
258
|
-
def agua(text, options = {})
|
259
|
-
alimento = [text]
|
260
|
-
alimento <<"(#{[options[:litros]]})" if options[:litros]
|
261
|
-
@compo_nutri << alimento
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
lentejas_arroz = Plato.new("Lentejas con arroz, salsa de tomate, huevo y platano a la plancha") do
|
266
|
-
vegetal "Tomate",:porcion => "2 piezas pequeñas"
|
267
|
-
fruta "Platano",:gramos => 20
|
268
|
-
cereal "Arroz",:porcion => "1 taza"
|
269
|
-
proteina "Lentejas",:porcion => "1/2 cucharon"
|
270
|
-
aceite "Aceite de oliva",:porcion => "1/2 cucharada"
|
271
|
-
proteina "Huevo",:porcion => "1 pieza"
|
272
|
-
end
|
273
|
-
puts lentejas_arroz
|
274
|
-
#puts lentejas_arroz.to_s
|
275
|
-
#ya funciona la otra clase
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
# @prueba = Ordenacion.new
|
293
|
-
# puts ('************* ELEMENTOS SIN ORDENAR *********************************')
|
294
|
-
#
|
295
|
-
# @a = @prueba.calculo_calorias
|
296
|
-
# #@a.to_a
|
297
|
-
# p(@a)
|
298
|
-
#
|
299
|
-
# puts ('**************** ELEMENTOS ORDENADOS CON BUCLE FOR ********************')
|
300
|
-
# @b = @prueba.burbuja_for(@a)
|
301
|
-
# p(@b)
|
302
|
-
#
|
303
|
-
# puts ('************** ELEMENTOS ORDENADOS CON BUCLE EACH ******************************')
|
304
|
-
# @b = @prueba.burbuja_each(@a)
|
305
|
-
# p(@b)
|
306
|
-
#
|
307
|
-
# puts ('***************** ELEMENTOS ORDENADOS METODO SORT ****************')
|
308
|
-
# @b = @a.sort
|
309
|
-
# p(@b)
|
310
|
-
#
|
311
|
-
# # @texto = @prueba.to_s
|
312
|
-
# # puts(@texto)
|
313
|
-
#
|
314
|
-
#
|
315
|
-
#
|
316
|
-
#
|
317
|
-
# Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x|
|
318
|
-
# tf = x.report("con bucle for") { @prueba.burbuja_for(@a) }
|
319
|
-
# tf = x.report("con bucle each") { @prueba.burbuja_each(@a) }
|
320
|
-
# tf = x.report("con metodo sort") { @a.sort }
|
321
|
-
# end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require "Alimento/alimentos.rb"
|
2
|
-
|
3
|
-
|
4
|
-
class Tipo_alimento < Alimentos
|
5
|
-
|
6
|
-
def self.description
|
7
|
-
"clase que representa el tipo de aliment"
|
8
|
-
end
|
9
|
-
|
10
|
-
attr_accessor :tipo_alimento
|
11
|
-
|
12
|
-
def initialize (nombre_ali,proteinas,glucidos,lipidos,tipo_ali)
|
13
|
-
super(nombre_ali,proteinas,glucidos,lipidos)
|
14
|
-
@tipo_ali = tipo_ali
|
15
|
-
end
|
16
|
-
def to_s
|
17
|
-
s = "" #encadenamiento (chaining)
|
18
|
-
s << "#{@tipo_ali}\n"
|
19
|
-
s << super.to_s
|
20
|
-
s
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
# @tipo_ali_1 = Tipo_alimento.new("huevo frito",14.1,0.0,19.5,"huevos lacteos y helados")
|
29
|
-
# puts (@tipo_ali_1.to_s)
|