menud 0.1.0

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.
@@ -0,0 +1,199 @@
1
+ # Author:: Alejandro Díaz Cueca(alu0100761948@ull.edu.es)
2
+ # Copyright:: Creative Commons
3
+ # License:: Distributes under the same terms as Ruby
4
+ #
5
+ # We create a struct to describe the configuration of a node
6
+ #
7
+
8
+
9
+ Nodo = Struct.new(:value, :next)
10
+ Nodo_ = Struct.new(:prev, :value, :next)
11
+
12
+
13
+ #
14
+ # Lista class
15
+ # Here we have a simple linked list
16
+ # * initialize
17
+ # * elemento
18
+ # * insertar_elemento
19
+ # * extraer_elemento
20
+
21
+
22
+
23
+
24
+
25
+ class Lista
26
+
27
+ # We set to nil value the initial node
28
+ def initialize ()
29
+
30
+ @elemento = Nodo.new(nil)
31
+ end
32
+
33
+ # Just to define the element
34
+ def elemento
35
+
36
+ @elemento
37
+ end
38
+
39
+ # We insert a new element on the simple linked list
40
+ def insertar_elemento(nodo)
41
+
42
+ if @elemento != nil
43
+
44
+ nodo.next = @elemento
45
+ @elemento = nodo
46
+ end
47
+ end
48
+
49
+
50
+ # We extract a element from the simple linked list
51
+ def extraer_elemento
52
+
53
+ aux = @elemento
54
+ @elemento = @elemento.next
55
+ aux.value
56
+ end
57
+
58
+ end
59
+
60
+
61
+
62
+ #
63
+ # Lista_doble class
64
+ # It's a double linked list in this case, we used a struct to describe the class too
65
+ # we include the mixin Enumerable
66
+ # * empty
67
+ # * initialize
68
+ # * insertar_elemento
69
+ # * extraer_elemento
70
+ # * each
71
+
72
+ class Lista_doble
73
+
74
+ include Enumerable
75
+
76
+ attr_accessor :head, :tail
77
+
78
+
79
+ # We set the initial node to nil and we see if the dll is empty
80
+ def empty?
81
+
82
+ @head == nil
83
+ end
84
+
85
+ # We set the initial and last node to nil
86
+ def initialize()
87
+
88
+ @head = nil
89
+ @tail = nil
90
+ end
91
+
92
+ # We insert a new element on the double linked list
93
+ def insertar_elemento(nodo)
94
+
95
+ @nodo = Nodo_.new(nil, nodo, nil)
96
+
97
+ if @tail == nil
98
+ @head = @nodo
99
+ @tail = @nodo
100
+ #@nodo
101
+ else
102
+ @nodo.next = @head
103
+ @head.prev = @nodo
104
+ @head = @nodo
105
+ #@nodo
106
+ end
107
+
108
+ end
109
+
110
+
111
+ # We extract a new element on the double linked list
112
+ def extraer_elemento
113
+
114
+ @nodo = Nodo_.new(nil, @head.value, nil)
115
+
116
+ @head = @head.next
117
+ @head.prev = nil
118
+ return @nodo
119
+
120
+ #nodo = @head
121
+ #if @head.next == nil
122
+ # @head = nil
123
+ # else
124
+ # @head = @head.next
125
+ #end
126
+ #return nodo
127
+
128
+ #nodo = @head
129
+ #@head = @head.next
130
+
131
+ #nodo.next = nil
132
+ #nodo.prev = nil
133
+
134
+ #if @head == nil
135
+ # @tail = nil
136
+ #end
137
+
138
+ #return nodo
139
+ end
140
+
141
+
142
+ # Its a define like a iteration on the nodes of the list to get the value
143
+ def each
144
+ enum = @head
145
+ while (enum != nil)
146
+ yield enum.value
147
+ enum = enum.next
148
+ end
149
+ end
150
+
151
+
152
+ def convert_a_for
153
+
154
+
155
+ n_array= []
156
+
157
+ enum=@head
158
+
159
+ for i in self do
160
+
161
+ n_array.push(enum.value)
162
+ enum = enum.next
163
+ end
164
+ n_array.bubblefor
165
+
166
+ end
167
+
168
+
169
+ def convert_a_each
170
+
171
+
172
+ n_array= []
173
+
174
+ enum=@head
175
+
176
+ for i in self do
177
+
178
+ n_array.push(enum.value)
179
+ enum = enum.next
180
+ end
181
+ n_array.bubbleach
182
+
183
+ end
184
+
185
+
186
+
187
+
188
+
189
+ end
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
@@ -0,0 +1,420 @@
1
+
2
+ # Author:: Alejandro Díaz Cueca(alu0100761948@ull.edu.es)
3
+ # Copyright:: Creative Commons
4
+ # License:: Distributes under the same terms as Ruby
5
+
6
+
7
+
8
+ # This source files contains the superclass Individuo and EtiquetaN
9
+
10
+ # Superclass Individuo is use to get the information about a person and his anthropometric measures
11
+
12
+ # including mixin Comparable
13
+ # * method initialize
14
+ # * method to_s
15
+ # * method to_f
16
+ # * method to_i
17
+ # * method <=>
18
+ #
19
+
20
+ class Individuo
21
+
22
+
23
+
24
+ include Comparable
25
+
26
+ attr_accessor :nombre, :apellidos, :edad, :genero, :peso, :talla, :cadera, :cintura, :imc, :porcentgrasa, :rcc, :peso_t_i, :gasto_e_basal, :efecto_t_a, :gasto_ef, :factor_actvf, :gasto_e_total
27
+
28
+ # Method to initialize every anthropometric measures
29
+ def initialize(nombre, apellidos, edad, genero, peso, talla, cadera, cintura, imc, porcentgrasa, rcc, peso_t_i, gasto_e_basal, efecto_t_a, gasto_ef, factor_actvf, gasto_e_total)
30
+
31
+
32
+
33
+
34
+
35
+ @nombre = nombre
36
+ @apellidos = apellidos
37
+ @edad = edad
38
+ @genero = genero
39
+ @peso = peso
40
+ @talla = talla
41
+ @cadera = cadera
42
+ @cintura = cintura
43
+ @imc = imc
44
+ @porcentgrasa = porcentgrasa
45
+ @rcc = rcc
46
+ @peso_t_i = peso_t_i
47
+ @gasto_e_basal = gasto_e_basal
48
+ @efecto_t_a = efecto_t_a
49
+ @gasto_ef = gasto_ef
50
+ @factor_actvf = factor_actvf
51
+ @gasto_e_total = gasto_e_total
52
+
53
+
54
+
55
+ end
56
+ =begin
57
+ # Method to transform into string
58
+ def to_s
59
+
60
+ "#{@nombre}\n"
61
+ "#{@apellidos}\n"
62
+
63
+ end
64
+ =end
65
+ # Method to get the value of imc and do the comparison
66
+ def <=> (other)
67
+
68
+
69
+ @imc <=> other.imc
70
+
71
+ end
72
+
73
+
74
+ =begin
75
+ # Method to transform into int
76
+ def to_i
77
+
78
+
79
+ "#{@edad}"
80
+ "#{@genero}"
81
+ "#{@peso}"
82
+
83
+ end
84
+
85
+ # Method to transform into float
86
+ def to_f
87
+
88
+
89
+
90
+ "#{@talla}"
91
+ "#{@cadera}"
92
+ "#{@cintura}"
93
+ "#{@imc}"
94
+ "#{@porcentgrasa}"
95
+ "#{@rcc}"
96
+ "#{@peso_t_i}"
97
+ "#{@gasto_e_basal}"
98
+ "#{@efecto_t_a}"
99
+ "#{@gasto_ef}"
100
+ "#{@factor_actvf}"
101
+ "#{@gasto_e_total}"
102
+
103
+
104
+
105
+
106
+
107
+ end
108
+ =end
109
+
110
+ def peso_total_ideal
111
+
112
+ @peso_t_i = ((@talla - 150) * 0.75 + 50)
113
+
114
+
115
+ end
116
+
117
+ def gasto_energetico_basal
118
+
119
+ if (@sexo = 1)
120
+
121
+ @gasto_e_basal = ((10 * @peso) + (6.25 * @talla) - (5 * @edad) + 5 )
122
+
123
+ elsif
124
+ @gasto_e_basal = ((10 * @peso) + (6.25 * @talla) - (5 * @edad) - 161 )
125
+ end
126
+
127
+
128
+ end
129
+
130
+ def efecto_termogeno_alimentos
131
+
132
+ @efecto_t_a = (@gasto_e_basal * 0.10)
133
+
134
+ end
135
+
136
+
137
+ def gasto_actividadf
138
+
139
+ @gasto_ef = (@gasto_e_basal * @factor_actvf).round(2)
140
+
141
+ end
142
+
143
+
144
+ def gasto_energetico_t
145
+
146
+ @gasto_e_total = (@gasto_e_basal + @efecto_t_a + @gasto_ef)
147
+
148
+ end
149
+
150
+
151
+
152
+
153
+
154
+
155
+ end
156
+
157
+
158
+ #
159
+ # Class Consulta derived from the superclass Individuo
160
+
161
+ # * method initialize
162
+ # * method to_s
163
+ # * method to_f
164
+ # * method to_i
165
+
166
+ class Consulta < Individuo
167
+ attr_accessor :paciente, :tratamiento
168
+
169
+ #Method to initialize every anthropometric measures and get if this person is patient and have a treatment already assignment
170
+ def initialize(nombre, apellidos, edad, genero, peso, talla, cadera, cintura, imc, porcentgrasa, rcc, peso_t_i, gasto_e_basal, efecto_t_a, gasto_ef, factor_actvf, gasto_e_total, paciente, tratamiento)
171
+
172
+
173
+ super :nombre, :apellidos, :edad, :genero, :peso, :talla, :cadera, :cintura, :imc, :porcentgrasa, :rcc, :peso_t_i, :gasto_e_basal, :efecto_t_a, :gasto_ef, :factor_actvf, :gasto_e_total
174
+
175
+
176
+ @nombre = nombre
177
+ @apellidos = apellidos
178
+ @edad = edad
179
+ @genero = genero
180
+ @peso = peso
181
+ @talla = talla
182
+ @cadera = cadera
183
+ @cintura = cintura
184
+ @imc = imc
185
+ @porcentgrasa = porcentgrasa
186
+ @rcc = rcc
187
+ @peso_t_i = peso_t_i
188
+ @gasto_e_basal = gasto_e_basal
189
+ @efecto_t_a = efecto_t_a
190
+ @gasto_ef = gasto_ef
191
+ @factor_actvf = factor_actvf
192
+ @gasto_e_total = gasto_e_total
193
+ @paciente = paciente
194
+ @tratamiento = tratamiento
195
+
196
+
197
+
198
+ end
199
+
200
+ # Method to transform into string
201
+ =begin
202
+ def to_s
203
+
204
+ super :nombre, :apellidos
205
+
206
+ "#{@nombre}"
207
+ "#{@apellidos}"
208
+ "#{@paciente}"
209
+ "#{@tratamiento}"
210
+
211
+ end
212
+
213
+
214
+
215
+ # Method to transform into int
216
+ def to_i
217
+
218
+ super :edad, :genero, :peso
219
+
220
+ "#{@edad}"
221
+ "#{@genero}"
222
+ "#{@peso}"
223
+
224
+ end
225
+
226
+ # Method to transform into float
227
+ def to_f
228
+
229
+ super :talla, :cadera, :cintura, :imc, :porcentgrasa, :rcc, :peso_t_i, :gasto_e_basal, :efecto_t_a, :gasto_ef, :factor_actvf, :gasto_e_total
230
+
231
+
232
+ "#{@talla}"
233
+ "#{@cadera}"
234
+ "#{@cintura}"
235
+ "#{@imc}"
236
+ "#{@porcentgrasa}"
237
+ "#{@rcc}"
238
+ "#{@peso_t_i}"
239
+ "#{@gasto_e_basal}"
240
+ "#{@efecto_t_a}"
241
+ "#{@gasto_ef}"
242
+ "#{@factor_actvf}"
243
+ "#{@gasto_e_total}"
244
+
245
+
246
+
247
+ end
248
+ =end
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+ end
260
+
261
+ #
262
+ # Superclass EtiquetaN is use to get the information about a product and its nutritional label
263
+
264
+ # including mixin Comparable
265
+ # * method initialize
266
+ # * method to_s
267
+ # * method to_f
268
+ # * method <=>
269
+ #
270
+
271
+
272
+
273
+ class EtiquetaN
274
+
275
+ include Comparable
276
+
277
+
278
+ attr_accessor :netiqueta, :venergeticokJ, :venergeticokcal, :cantgrasas, :cantgrasasat, :hidratosc, :azucares, :fibraa, :proteinas, :sales
279
+
280
+ # Initializing every characteristic about nutritional labels and his name
281
+ def initialize(netiqueta, venergeticokJ, venergeticokcal, cantgrasas, cantgrasasat, hidratosc, azucares, fibraa, proteinas, sales)
282
+
283
+ @netiqueta = netiqueta
284
+ @venergeticokJ = venergeticokJ
285
+ @venergeticokcal = venergeticokcal
286
+ @cantgrasas = cantgrasas
287
+ @cantgrasasat = cantgrasasat
288
+ @hidratosc = hidratosc
289
+ @azucares = azucares
290
+ @fibraa = fibraa
291
+ @proteinas = proteinas
292
+ @sales = sales
293
+
294
+ end
295
+
296
+ # Method to transform into string
297
+ =begin
298
+ def to_s
299
+
300
+ #"#{@netiqueta}\n#{@venergeticokJ}\n#{@venergeticokcal}\n#{@cantgrasas}\n#{@cantgrasasat}\n#{@hidratosc})\n#{@azucares}\n#{@fibraa}\n#{@proteinas}\n#{@sales}"
301
+
302
+ "#{@netiqueta}"
303
+
304
+ end
305
+ =end
306
+
307
+ #Method to get the value of proteins and do the comparison
308
+ def <=> (other)
309
+
310
+
311
+ @proteinas <=> other.proteinas
312
+
313
+ end
314
+
315
+ #Method to transform into float
316
+ =begin
317
+ def to_f
318
+
319
+ "#{@venergeticokJ}"
320
+ "#{@venergeticokcal}"
321
+ "#{@cantgrasas}"
322
+ "#{@cantgrasasat}"
323
+ "#{@hidratosc}"
324
+ "#{@azucares}"
325
+ "#{@proteinas}"
326
+ "#{@sales}"
327
+
328
+
329
+ end
330
+ =end
331
+
332
+ end
333
+
334
+
335
+ #
336
+ # Class Tproducto deriven from the superclass EtiquetaN
337
+ # adding more features about nutritional labels
338
+
339
+ # * method initialize
340
+ # * method to_s
341
+ # * method to_f
342
+
343
+
344
+
345
+
346
+
347
+ class TProducto < EtiquetaN
348
+ attr_accessor :fcaducidad, :tipo, :aceitepalma
349
+
350
+ #Method to initialize every feature about the nutrition label also adding some more
351
+ def initialize(netiqueta, venergeticokJ, venergeticokcal, cantgrasas, cantgrasasat, hidratosc, azucares, fibraa, proteinas, sales, fcaducidad, tipo, aceitepalma)
352
+
353
+
354
+ super :netiqueta, :venergeticokJ, :venergeticokcal, :cantgrasas, :cantgrasasat, :hidratosc, :azucares, :fibraa, :proteinas, :sales
355
+
356
+
357
+ @netiqueta = netiqueta
358
+ @venergeticokJ = venergeticokJ
359
+ @venergeticokcal = venergeticokcal
360
+ @cantgrasas = cantgrasas
361
+ @cantgrasasat = cantgrasasat
362
+ @hidratosc = hidratosc
363
+ @azucares = azucares
364
+ @fibraa = fibraa
365
+ @proteinas = proteinas
366
+ @sales = sales
367
+ @fcaducidad = fcaducidad
368
+ @tipo = tipo
369
+ @aceitepalma = aceitepalma
370
+
371
+
372
+
373
+
374
+
375
+ end
376
+
377
+ # Method to transform into string
378
+ =begin
379
+ def to_s
380
+
381
+ #"#{@netiqueta}\n#{@venergeticokJ}\n#{@venergeticokcal}\n#{@cantgrasas}\n#{@cantgrasasat}\n#{@hidratosc}\n#{@azucares}\n#{@fibraa}\n#{@proteinas}\n#{@sales}\n#{@fcaducidad}\n#{@tipo}\n#{@aceitepalma}"
382
+
383
+ super :netiqueta
384
+
385
+ "#{@netiqueta}"
386
+ "#{@fcaducidad}"
387
+ "#{@tipo}"
388
+ "#{@aceitepalma}"
389
+
390
+
391
+
392
+ end
393
+
394
+ # Method to transform into float
395
+ def to_f
396
+
397
+ super :venergeticokJ, :venergeticokcal, :cantgrasas, :cantgrasasat, :hidratosc, :azucares, :proteinas, :sales
398
+
399
+ "#{@venergeticokJ}"
400
+ "#{@venergeticokcal}"
401
+ "#{@cantgrasas}"
402
+ "#{@cantgrasasat}"
403
+ "#{@hidratosc}"
404
+ "#{@azucares}"
405
+ "#{@proteinas}"
406
+ "#{@sales}"
407
+
408
+
409
+ end
410
+ =end
411
+
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+ end