Alimento 0.1.0 → 30.30.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,110 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>
7
- Top Level Namespace
8
-
9
- &mdash; Documentation by YARD 0.9.9
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
-
15
- <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
-
17
- <script type="text/javascript" charset="utf-8">
18
- pathId = "";
19
- relpath = '';
20
- </script>
21
-
22
-
23
- <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
-
25
- <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
-
27
-
28
- </head>
29
- <body>
30
- <div class="nav_wrap">
31
- <iframe id="nav" src="class_list.html?1"></iframe>
32
- <div id="resizer"></div>
33
- </div>
34
-
35
- <div id="main" tabindex="-1">
36
- <div id="header">
37
- <div id="menu">
38
-
39
- <a href="_index.html">Index</a> &raquo;
40
-
41
-
42
- <span class="title">Top Level Namespace</span>
43
-
44
- </div>
45
-
46
- <div id="search">
47
-
48
- <a class="full_list_link" id="class_list_link"
49
- href="class_list.html">
50
-
51
- <svg width="24" height="24">
52
- <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
- <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
- <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
- </svg>
56
- </a>
57
-
58
- </div>
59
- <div class="clear"></div>
60
- </div>
61
-
62
- <div id="content"><h1>Top Level Namespace
63
-
64
-
65
-
66
- </h1>
67
- <div class="box_info">
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
- </div>
80
-
81
- <h2>Defined Under Namespace</h2>
82
- <p class="children">
83
-
84
-
85
-
86
-
87
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="Alimentos.html" title="Alimentos (class)">Alimentos</a></span>, <span class='object_link'><a href="ListaDoble.html" title="ListaDoble (class)">ListaDoble</a></span>, <span class='object_link'><a href="Nodo.html" title="Nodo (class)">Nodo</a></span>
88
-
89
-
90
- </p>
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
- </div>
101
-
102
- <div id="footer">
103
- Generated on Wed Nov 15 11:51:03 2017 by
104
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
- 0.9.9 (ruby-2.3.3).
106
- </div>
107
-
108
- </div>
109
- </body>
110
- </html>
@@ -1,333 +0,0 @@
1
- #! /usr/local/rvm/rubies/ruby-2.1.1/bin/ruby
2
-
3
- class Glucemico
4
- #include Comparable
5
- TIEMPO_MUESTRA = 24
6
- NUM_ALIMENTOS = 4
7
- attr_accessor :tiempo
8
- attr_accessor :individuo1,:ind1_compota_manzana,:ind1_yogurt,:ind1_chocolate,:ind1_glucosa
9
- attr_accessor :individuo2,:ind2_compota_manzana,:ind2_yogurt,:ind2_chocolate,:ind2_glucosa
10
-
11
- attr_accessor :datos_ind1,:datos_ind2,:g
12
-
13
- def self.description
14
- "clase que calcula el indice glucemico de individuos"
15
- end
16
-
17
- def initialize
18
- @alimentos_texto = ['glucosa','compota_manzana','yogurt','chocolate']
19
- @tiempo = [0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120]
20
-
21
- @individuo1 = 'ind1'
22
- @ind1_compota_manzana = [6.7,6.5,6.8,6.9,7.0,7.1,6.9,6.9,6.9,6.7,6.9,7.3,7.0,7.0,7.2,7.1,6.8,7.2,7.3,7.0,6.8,6.7,6.8,6.7,6.9]
23
- @ind1_yogurt = [6.1,6.6,6.3,6.3,6.1,6.9,6.8,6.5,6.4,6.9,6.8,6.5,6.3,6.2,6.7,6.2,5.9,5.8,5.8,5.8,5.8,5.8,5.9,6.2,6.4]
24
- @ind1_chocolate = [6.5,6.5,6.7,6.5,6.5,6.8,6.7,6.2,6.5,7.2,6.9,7.0,6.3,6.2,6.1,5.9,5.8,6.1,6.7,6.7,6.6,6.7,6.9,7.2,7.1]
25
- @ind1_glucosa = [4.9,5.3,5.9,6.7,7.2,7.6,8.0,8.2,8.2,8.4,8.3,8.3,8.0,7.5,7.1,6.8,6.8,6.9,6.8,6.3,6.2,6.3,6.2,6.3,6.1]
26
- @datos_ind1 = [@ind1_glucosa,@ind1_compota_manzana,@ind1_yogurt,@ind1_chocolate,@ind1_glucosa]
27
-
28
- @individuo2 = 'ind2'
29
- @ind2_compota_manzana = [4.6,4.8,5.3,5.6,6.1,6.5,6.6,7.0,7.0,6.8,6.4,6.3,6.1,6.1,6.2,6.0,6.1,6.1,6.2,6.3,6.4,6.1,6.1,5.7,5.9]
30
- @ind2_yogurt = [4.9,4.9,5.2,5.8,6.5,7.0,7.2,7.3,7.3,6.6,6.2,6.1,6.0,6.1,5.9,5.9,5.9,5.9,5.8,5.8,5.5,5.5,5.6,5.9,5.9]
31
- @ind2_chocolate = [4.6,4.6,4.7,4.7,4.8,4.7,4.8,4.8,4.6,4.4,4.7,4.7,4.8,4.7,5.2,5.9,5.9,5.7,5.4,5.3,5.1,4.8,4.8,4.9,5.9]
32
- @ind2_glucosa = [6.3,5.4,5.6,5.7,6.5,7.4,7.9,7.4,7.7,7.9,7.9,7.8,7.8,7.8,8.0,8.5,9.4,10.8,10.5,9.1,8.9,8.3,7.7,7.6,7.5]
33
- @datos_ind2 = [@ind2_glucosa,@ind2_compota_manzana,@ind2_yogurt,@ind2_chocolate]
34
-
35
- @datos = [@datos_ind1,@datos_ind2]
36
-
37
- @g = [[1,2,3],[4,5,6]]
38
-
39
- end
40
-
41
- # def aibc
42
- # i = 0
43
- # r = []
44
- # while i < @g.size
45
- # index = 1
46
- # s = []
47
- # while (index < @g[i].size)
48
- # if (@g[i][index] < @g[i][0])
49
- # s << 0.0
50
- # else
51
- # s << (((@g[i][index] - @g[i][0]) + (@g[i][index-1] - @g[i][0]))/2)*5
52
- # end
53
- # index = index + 1
54
- # end
55
- # r << s
56
- # i = i + 1
57
- # end
58
-
59
- #se aplica solo a un individuo
60
- def formula_AIBC (alimentos_usuario)
61
- i = 0
62
- r = []
63
- #each_byte
64
-
65
- alimentos_usuario.each_with_index do |valor,i|
66
- #puts "#{valor} at #{i}"
67
-
68
- #i.to_f
69
- index=1
70
- s=[]
71
- valor.each_with_index do |valor2,index|
72
- #puts "#{valor2} at #{index}"
73
- if (alimentos_usuario[i][index] < alimentos_usuario[i][0])
74
-
75
- s << (0.0)
76
- else
77
- #s << (((alimento[i][index].to_f - alimento[i][0].to_f) + (alimento[i][index-1].to_f - alimento[i][0].to_f))/2)*5
78
- a = (alimentos_usuario[i][index].to_f - alimentos_usuario[i][0].to_f)
79
- b = (alimentos_usuario[i][index-1] - alimentos_usuario[i][0])
80
- s << (((((a)+(b))/2.0)*5.0))
81
-
82
- end
83
- #index += 1
84
-
85
-
86
- end
87
- #p (s)
88
- r << s
89
- #i += 1
90
-
91
- end
92
-
93
- # suma = []
94
- # j = 0
95
- # while j < @g.size
96
- # k = 0
97
- # s = 0
98
- # while k < r[j].size
99
- # s = s + r[j][k]
100
- # k = k + 1
101
- # end
102
- # suma << s
103
- # j = j + 1
104
- # end
105
- # suma
106
- # end
107
- suma = []
108
- j = 0
109
- #puts "locoloco #{r}"
110
- alimentos_usuario.each_with_index do |valor, j|
111
- k = 0
112
- s = 0
113
- p = valor.reduce(:+)
114
- # alimentos_usuario.each_with_index do |valor2,k|
115
- # s = s + r[j][k]
116
- # #valor2
117
- # #s = r.reduce(:+)
118
- # #k = k + 1
119
- # end
120
- suma << p
121
- #j = j+1
122
- #puts "locoloco #{p}"
123
- end
124
- suma
125
- #suma = r.reduce {:+}
126
- #puts (suma)
127
- end
128
- #e
129
-
130
-
131
- def IG
132
-
133
-
134
- a = formula_AIBC(@datos_ind1)
135
- b = formula_AIBC(@datos_ind2)
136
- #(a b).each_with_index do |i|
137
- salida=[]
138
- result=[]
139
- for i in 1..NUM_ALIMENTOS-1
140
- parte1 = (a[i].to_f/a[0].to_f)*100
141
- parte2 = (b[i].to_f/b[0].to_f)*100
142
- result = ((parte1)+(parte2))/2
143
- puts "alimento #{@alimentos_texto[i]} valor IG #{result}"
144
- #salida.insert (result)
145
- end
146
-
147
- # a.zip(b).each_with_index do |dato,i|
148
- # #puts (dato)
149
- # parte1 = (a[i+1].to_f/a[0].to_f)*100
150
- # parte2 = (b[i+1].to_f/b[0].to_f)*100
151
- # result = ((parte1)+(parte2))/2
152
- # puts "alimento #{@alimentos_texto[i+1]} valor IG #{result}"
153
- # end
154
-
155
-
156
-
157
-
158
- #kaka = formula_AIBC(@datos_ind1[i][j],i)
159
-
160
- end
161
-
162
- end
163
-
164
-
165
- @prueba = Glucemico.new
166
- #puts "prueba #{@prueba.formula_AIBC}"
167
- @prueba.IG
168
- #puts (@prueba.ind2_compota_manzana)
169
-
170
- #puts "prueba2 #{@prueba.IG}"
171
- #puts "prueba #{formula_IG}"
172
- #puts "prueba #{@prueba.datos_ind1[0][0]}"
173
-
174
- #puts (@prueba.aibc)s
175
-
176
- #puts "IG_yogurt #{IG_yogurt}"
177
-
178
-
179
-
180
- # # esta formula se aplica para dos individuo
181
- #
182
- # def self.formula_IG (alimento)
183
- # result = 0
184
- # result = (formula_IG_IND(alimento))/ 2
185
- #
186
- # #result = (formula_IG_IND(@compota_manzana) + formula_IG_IND(@yogurt) + formula_IG_IND(@chocolate)) / 2
187
- # return (result)
188
- # end
189
- #
190
- # # def + (other)
191
- # # Glucemico.new(individuo+other.individuo,tiempo+other.tiempo,compota_manzana+other.compota_manzana,yogurt+other.yogurt,
192
- # # chocolate+other.chocolate,glucosa+other.glucosa)
193
- # # end
194
- #
195
- #
196
- # ##################################################################################################
197
- # def individuo_to_s
198
- # imprime = "individuo: #{formula_IG(@individuo)}\n" #número de porciones
199
- #
200
- # return imprime
201
- # end
202
- #
203
- # def formula_AIBC_to_s (alimento)
204
- # imprime = "#{formula_AIBC(alimento)}" #formula
205
- #
206
- # return imprime
207
- # end
208
- #
209
- # def formula_IG_IND_to_s (alimento)
210
- # imprime = "#{formula_IG_IND(alimento)}" #formula
211
- #
212
- # return imprime
213
- # end
214
- #
215
- # def formula_IG_to_s
216
- # imprime = "#{formula_IG(alimento)}" #formula
217
- #
218
- # return imprime
219
- # end
220
- #
221
- #
222
- # # def ingredientes_to_s
223
- # # imprime = "\n"
224
- # # imprime << "Ingredientes:\n"
225
- # # imprime << "#{ingredientes.join(', ')}\n\n" #con el join añade la , y el espacio entre los elementos del array
226
- #
227
- #
228
- #
229
- # # def instrucciones_to_s
230
- # # imprime = "Instrucciones:\n"
231
- # # instrucciones.each_with_index do |instruccion, index| #nos da el valor de cada elemento del array y su indice
232
- # # imprime << "#{index + 1}) #{instruccion}\n" #index + 1 para que no empiece en 0
233
- # # end
234
- #
235
- #
236
- #
237
- #
238
- # def to_s
239
- #
240
- # return (individuo_to_s + indice_compota_manzana_to_s + indice_yogurt_to_s + indice_chocolate_to_s )
241
- #
242
- # end
243
- # end
244
- #
245
- #
246
- # # class individuo
247
- # # attr_accessor :ind
248
- # #
249
- # # def initialize(ind)
250
- # # @ind = ind
251
- # # end
252
- # # def formula_IG_to_s
253
- # # imprime = "#{formula_IG(alimento)}" #formula
254
- # #
255
- # # return imprime
256
- # # end
257
- # #
258
- # # def formula_IG_IND_to_s (alimento)
259
- # # imprime = "#{formula_IG_IND(alimento)}" #formula
260
- # #
261
- # # return imprime
262
- # # end
263
- # # end
264
- #
265
- #
266
- #
267
- #
268
- # # individuo,tiempo,compota_manzana,yogurt,chocolate,glucosa
269
- #
270
- # @tiempo = %w[0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120]
271
- # @ind1_compota_manzana = %w[6.7 6.5 6.8 6.9 7.0 7.1 6.9 6.9 6.9 6.7 6.9 7.3 7.0 7.0 7.2 7.1 6.8 7.2 7.3 7.0 6.8 6.7 6.8 6.7 6.9]
272
- # @ind1_yogurt = %w[6.1 6.6 6.3 6.3 6.1 6.9 6.8 6.5 6.4 6.9 6.8 6.5 6.3 6.2 6.7 6.2 5.9 5.8 5.8 5.8 5.8 5.8 5.9 6.2 6.4]
273
- # @ind1_chocolate = %w[6.5 6.5 6.7 6.5 6.5 6.8 6.7 6.2 6.5 7.2 6.9 7.0 6.3 6.2 6.1 5.9 5.8 6.1 6.7 6.7 6.6 6.7 6.9 7.2 7.1]
274
- # @ind1_glucosa = %w[4.9 5.3 5.9 6.7 7.2 7.6 8.0 8.2 8.2 8.4 8.3 8.3 8.0 7.5 7.1 6.8 6.8 6.9 6.8 6.3 6.2 6.3 6.2 6.3 6.1]
275
- # @individuo1 = Glucemico.new("ind1",@tiempo , @ind1_compota_manzana , @ind1_yogurt , @ind1_chocolate , @ind1_glucosa)
276
- # # acordarse de quitar espacio en blanco en el new(
277
- # #puts @individuo1
278
- # puts (Glucemico.description)
279
- # puts
280
- # puts "AIBC_compota_manzana #{@individuo1.formula_AIBC(@ind1_compota_manzana)}"
281
- # puts "AIBC_yogurt #{@individuo1.formula_AIBC(@ind1_yogurt)}"
282
- # puts "AIBC_chocolate #{@individuo1.formula_AIBC(@ind1_chocolate)}"
283
- # # puts "Compota de manzana #{@individuo1.formula_AIBC (@ind1_compota_manzana)}"
284
- # # puts "yogurt #{@individuo1.formula_AIBC (@ind1_yogurt)}"
285
- # # puts "chocolate #{@individuo1.formula_AIBC (@ind1_chocolate)}"
286
- # # puts "glucosa #{@individuo1.formula_AIBC (@ind1_glucosa)}"
287
- #
288
- # puts "IG_IND_compota_manzana #{@individuo1.formula_IG_IND(@ind1_compota_manzana)}"
289
- # puts "IG_IND_yogurt #{@individuo1.formula_IG_IND(@ind1_yogurt)}"
290
- # puts "IG_IND_chocolate #{@individuo1.formula_IG_IND(@ind1_chocolate)}"
291
- #
292
- # #puts "#{@individuo1.to_s()}"
293
- #
294
- # # puts "Compota de manzana #{individuo1.formula_IG (@ind1_compota_manzana)}"
295
- # # puts "yogurt #{individuo1.formula_IG (@ind1_yogurt)}"
296
- # # puts "chocolate #{individuo1.formula_IG (@ind1_chocolate)}"
297
- # # puts "glucosa #{individuo1.formula_IG (@ind1_glucosa)}"
298
- # @ind2_compota_manzana = %w[4.6 4.8 5.3 5.6 6.1 6.5 6.6 7.0 7.0 6.8 6.4 6.3 6.1 6.1 6.2 6.0 6.1 6.1 6.2 6.3 6.4 6.1 6.1 5.7 5.9]
299
- # @ind2_yogurt = %w[4.9 4.9 5.2 5.8 6.5 7.0 7.2 7.3 7.3 6.6 6.2 6.1 6.0 6.1 5.9 5.9 5.9 5.9 5.8 5.8 5.5 5.5 5.6 5.9 5.9]
300
- # @ind2_chocolate = %w[4.6 4.6 4.7 4.7 4.8 4.7 4.8 4.8 4.6 4.4 4.7 4.7 4.8 4.7 5.2 5.9 5.9 5.7 5.4 5.3 5.1 4.8 4.8 4.9 5.9]
301
- # @ind2_glucosa = %w[6.3 5.4 5.6 5.7 6.5 7.4 7.9 7.4 7.7 7.9 7.9 7.8 7.8 7.8 8.0 8.5 9.4 10.8 10.5 9.1 8.9 8.3 7.7 7.6 7.5]
302
- # @individuo2 = Glucemico.new("ind2",@tiempo,@ind2_compota_manzana,@ind2_yogurt,@ind2_chocolate,@ind2_glucosa)
303
- #
304
- # IG_compota_manzana = (@individuo1.formula_AIBC(@ind1_compota_manzana) + @individuo2.formula_AIBC(@ind1_compota_manzana))/2
305
- # puts "IG_compota_manzana #{IG_compota_manzana}"
306
- #
307
- # IG_yogurt = (@individuo1.formula_AIBC(@ind1_yogurt) + @individuo2.formula_AIBC(@ind2_yogurt))/2
308
- # puts "IG_yogurt #{IG_yogurt}"
309
- #
310
- # IG_chocolate = (@individuo1.formula_AIBC(@ind1_chocolate) + @individuo2.formula_AIBC(@ind2_chocolate))/2
311
- # puts "IG_chocolate #{IG_chocolate}"
312
- #
313
- # # IG_compota_manzana = ([@individuo1,@individuo2])
314
- # # @individuo = individuo.new(IG_compota_manzana)
315
- # # puts (@individuo)
316
- #
317
- # #result = @individuo1 + @individuo2
318
- # #puts (result.to_s)
319
- # @tiempo = %w[0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120]
320
- #
321
- # @individuo1 = 'ind1'
322
- # @ind1_compota_manzana = %w[6.7 6.5 6.8 6.9 7.0 7.1 6.9 6.9 6.9 6.7 6.9 7.3 7.0 7.0 7.2 7.1 6.8 7.2 7.3 7.0 6.8 6.7 6.8 6.7 6.9]
323
- # @ind1_yogurt = %w[6.1 6.6 6.3 6.3 6.1 6.9 6.8 6.5 6.4 6.9 6.8 6.5 6.3 6.2 6.7 6.2 5.9 5.8 5.8 5.8 5.8 5.8 5.9 6.2 6.4]
324
- # @ind1_chocolate = %w[6.5 6.5 6.7 6.5 6.5 6.8 6.7 6.2 6.5 7.2 6.9 7.0 6.3 6.2 6.1 5.9 5.8 6.1 6.7 6.7 6.6 6.7 6.9 7.2 7.1]
325
- # @ind1_glucosa = %w[4.9 5.3 5.9 6.7 7.2 7.6 8.0 8.2 8.2 8.4 8.3 8.3 8.0 7.5 7.1 6.8 6.8 6.9 6.8 6.3 6.2 6.3 6.2 6.3 6.1]
326
- # @datos_ind1 = [@individuo1,@tiempo,@ind1_compota_manzana,@ind1_yogurt,@ind1_chocolate,@ind1_glucosa]
327
- #
328
- # @individuo2 = 'ind2'
329
- # @ind2_compota_manzana = %w[4.6 4.8 5.3 5.6 6.1 6.5 6.6 7.0 7.0 6.8 6.4 6.3 6.1 6.1 6.2 6.0 6.1 6.1 6.2 6.3 6.4 6.1 6.1 5.7 5.9]
330
- # @ind2_yogurt = %w[4.9 4.9 5.2 5.8 6.5 7.0 7.2 7.3 7.3 6.6 6.2 6.1 6.0 6.1 5.9 5.9 5.9 5.9 5.8 5.8 5.5 5.5 5.6 5.9 5.9]
331
- # @ind2_chocolate = %w[4.6 4.6 4.7 4.7 4.8 4.7 4.8 4.8 4.6 4.4 4.7 4.7 4.8 4.7 5.2 5.9 5.9 5.7 5.4 5.3 5.1 4.8 4.8 4.9 5.9]
332
- # @ind2_glucosa = %w[6.3 5.4 5.6 5.7 6.5 7.4 7.9 7.4 7.7 7.9 7.9 7.8 7.8 7.8 8.0 8.5 9.4 10.8 10.5 9.1 8.9 8.3 7.7 7.6 7.5]
333
- # @datos_ind2 = [@individuo2,@tiempo,@ind2_compota_manzana,@ind2_yogurt,@ind2_chocolate,@ind2_glucosa]
@@ -1,155 +0,0 @@
1
- Nodo = Struct.new(:value, :next_node, :prev_node)
2
-
3
- # @author Miguel Parra Esquivel (miguelpe83)
4
- # @abstract
5
- # @since 0.6.0
6
-
7
-
8
- # @return [String] objeto convertidos con el formato string
9
-
10
- class ListaDoble
11
- include Enumerable
12
- #Contructor de la clase Lista
13
- def initialize
14
- @cabeza = nil
15
- @cola = nil
16
- end
17
-
18
- #Recorre la lista para el uso del módulo enumerable
19
- # @return [String] objeto convertidos con el formato string del recorrido de los nodos
20
- def each
21
- nodo_aux = @cabeza
22
- while nodo_aux != nil
23
- yield nodo_aux.value
24
- nodo_aux = nodo_aux.next_node
25
- end
26
- end
27
-
28
- #Devuelve el elemento inicial de la lista
29
- # @return [String] objeto convertidos con el formato string del nodo que quiere mostrar
30
- def get_inicio
31
- return @cabeza
32
- end
33
-
34
- #Devuelve el elemento final de la linea
35
- # @return [String] objeto convertidos con el formato string del nodo que quiere mostrar
36
- def get_final
37
- return @final
38
- end
39
-
40
- #Comprueba si la lista está vacía
41
- # def is_empty
42
- # # @inicio == nil
43
- # r = false
44
- # if(@cabeza == nil)
45
- # r = true
46
- # elsif
47
- # r = false
48
- # end
49
- # return r
50
- # end
51
-
52
- #Inserta un elemento por el inicio de la lista
53
- # @param elemento [String] nodo que quiere añadir
54
- # @return [String] objeto convertidos con el formato string del nodo que quiere añadir
55
- def insertar(elemento) #inserta por el inicio
56
- nodo_aux = Nodo.new(elemento, nil, nil)
57
-
58
- #if(is_empty())
59
-
60
-
61
- if (@cabeza == nil && @cola == nil)
62
- @cabeza = nodo_aux
63
- @final = nodo_aux
64
- @cabeza.next_node = nil
65
- @cabeza.prev_node = nil
66
- #@final = @inicio
67
- elsif
68
- aux = @cabeza
69
- @cabeza = nodo_aux
70
- @cabeza.next_node = aux
71
- @cabeza.prev_node = nil
72
- aux.prev_node = @cabeza
73
- end
74
- end
75
-
76
- #Inserta un elemento por el final de la lista
77
- # @param elemento [String] nodo que quieres añadir a la cola
78
- # @return [String] objeto convertidos con el formato string del nodo añadido
79
- def insertar_final(elemento)
80
- nodo_aux = Node.new(elemento, nil, nil)
81
- if(is_empty())
82
- @cabeza = nodo_aux
83
- @final = nodo_aux
84
- @cabeza.next_node = nil
85
- @cabeza.prev_node = nil
86
- @final.prev_node = nil
87
- @final.next_node = nil
88
- #@final = @inicio
89
- elsif
90
- aux = @final
91
- @final = nodo_aux
92
- @final.prev_node = aux
93
- @final.next_node = nil
94
- end
95
- end
96
-
97
- #Inserta varios elementos por el inicio de la lista
98
- # @param vector [String] insertar muchos nodos y llama a insertar un nodo
99
- # @return [String] objeto convertidos con el formato string de los nodos añadidos
100
- def insertar_muchos(vector) #inserta muchos por el inicio
101
- i=0
102
-
103
- while i<vector.length
104
- self.insertar(vector[i])
105
- i=i+1
106
- end
107
- end
108
-
109
- #Inserta varios elementos por el final de la lista
110
- #Se le pasa como argumento un vector con los elementos a insertar en la lista
111
- # @param vector [String] insertar muchos nodos y llama a insertar un nodo
112
- # @return [String] objeto convertidos con el formato string de los nodos añadidos
113
- def insertar_muchos_final(vector)
114
- i=0
115
-
116
- while i<vector.length
117
- self.insertar_final(vector[i])
118
- i=i+1
119
- end
120
- end
121
-
122
- #Extrae el inicio de la lista
123
- # @return [String] objeto convertidos con el formato string del nodo eliminado
124
- def extraer
125
- if(is_empty())
126
- return nil
127
- elsif
128
- node_aux = @inicio
129
- @inicio = @inicio.next_node
130
- node_aux.next_node = nil
131
- node_aux.prev_node = nil
132
- return node_aux.value
133
- end
134
- end
135
-
136
- #Extrae un elemento del final de la lista
137
- # def extraer_final
138
- # if(is_empty())
139
- # return nil
140
- # elsif
141
- # node_aux = @final
142
- # @final = @final.prev_node
143
- # if(@final!=nil)
144
- # @final.next_node=nil
145
- # elsif
146
- # @cabeza=nil
147
- # end
148
- # return node_aux.value
149
- # end
150
- # end
151
- # @attr_reader [Symbol] describe los getter de la clase
152
- # @attr_writer [Symbol] describe los setter de la clase
153
- attr_accessor :cabeza
154
- attr_accessor :cola
155
- end