etiqueta_nutricional 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +10 -0
- data/.travis.yml +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +111 -0
- data/Guardfile +82 -0
- data/README.md +24 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/doc/CODE_OF_CONDUCT_md.html +194 -0
- data/doc/Etiqueta.html +972 -0
- data/doc/EtiquetaNutricional.html +110 -0
- data/doc/EtiquetaNutricional/Error.html +103 -0
- data/doc/Gemfile.html +103 -0
- data/doc/Gemfile_lock.html +179 -0
- data/doc/Guardfile.html +179 -0
- data/doc/Individuo.html +373 -0
- data/doc/ListaEtiquetas.html +605 -0
- data/doc/Object.html +117 -0
- data/doc/Paciente.html +521 -0
- data/doc/README_md.html +128 -0
- data/doc/Rakefile.html +100 -0
- data/doc/bin/setup.html +100 -0
- data/doc/created.rid +18 -0
- data/doc/css/fonts.css +167 -0
- data/doc/css/rdoc.css +590 -0
- data/doc/etiqueta_nutricional_gemspec.html +140 -0
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +116 -0
- data/doc/js/darkfish.js +161 -0
- data/doc/js/jquery.js +4 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search.js +109 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js +229 -0
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +337 -0
- data/etiqueta_nutricional.gemspec +48 -0
- data/lib/etiqueta_nutricional.rb +13 -0
- data/lib/etiqueta_nutricional/array.rb +50 -0
- data/lib/etiqueta_nutricional/etiqueta_nutricional.rb +114 -0
- data/lib/etiqueta_nutricional/individuo.rb +39 -0
- data/lib/etiqueta_nutricional/lista_etiquetas.rb +198 -0
- data/lib/etiqueta_nutricional/menu.rb +66 -0
- data/lib/etiqueta_nutricional/paciente.rb +148 -0
- data/lib/etiqueta_nutricional/tabla.rb +45 -0
- data/lib/etiqueta_nutricional/version.rb +3 -0
- metadata +222 -0
@@ -0,0 +1,114 @@
|
|
1
|
+
class Etiqueta
|
2
|
+
|
3
|
+
include Comparable
|
4
|
+
|
5
|
+
attr_reader :nombre, :grasas, :grasas_saturadas, :hidratos_de_carbono, :azucares, :proteinas, :sal, :porciones
|
6
|
+
|
7
|
+
def initialize(nombre, grasas, grasas_saturadas, hidratos_de_carbono, azucares, proteinas, sal, porciones)
|
8
|
+
@nombre = nombre
|
9
|
+
@valor_energetico_kj = (grasas * 37) + (grasas_saturadas * 37) + (hidratos_de_carbono * 17) + (azucares * 17) + (proteinas * 17) + (sal * 25)
|
10
|
+
@valor_energetico_kcal = (grasas * 9) + (grasas_saturadas * 9) + (hidratos_de_carbono * 4) + (azucares * 4) + (proteinas * 4) + (sal * 6)
|
11
|
+
@grasas = grasas
|
12
|
+
@grasas_saturadas = grasas_saturadas
|
13
|
+
@hidratos_de_carbono = hidratos_de_carbono
|
14
|
+
@azucares = azucares
|
15
|
+
@proteinas = proteinas
|
16
|
+
@sal = sal
|
17
|
+
@numero_porciones = porciones[0]
|
18
|
+
@gramos_porcion = porciones[1]
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
def obtener_nombre
|
24
|
+
@nombre
|
25
|
+
end
|
26
|
+
|
27
|
+
def obtener_grasas
|
28
|
+
@grasas
|
29
|
+
end
|
30
|
+
|
31
|
+
def obtener_grasas_saturadas
|
32
|
+
@grasas_saturadas
|
33
|
+
end
|
34
|
+
|
35
|
+
def obtener_hidratos_carbono
|
36
|
+
@hidratos_de_carbono
|
37
|
+
end
|
38
|
+
|
39
|
+
def obtener_azucar
|
40
|
+
@azucares
|
41
|
+
end
|
42
|
+
|
43
|
+
def obtener_proteinas
|
44
|
+
@proteinas
|
45
|
+
end
|
46
|
+
|
47
|
+
def obtener_sal
|
48
|
+
@sal
|
49
|
+
end
|
50
|
+
|
51
|
+
def obtener_numero_porciones
|
52
|
+
@numero_porciones
|
53
|
+
end
|
54
|
+
|
55
|
+
def obtener_valor_energetico_kj
|
56
|
+
@valor_energetico_kj
|
57
|
+
end
|
58
|
+
|
59
|
+
def obtener_valor_energetico_kcal
|
60
|
+
@valor_energetico_kcal
|
61
|
+
end
|
62
|
+
|
63
|
+
def ir_valor_energetico_kj
|
64
|
+
(@valor_energetico_kj.round(2) / 8400 * 100).round(2)
|
65
|
+
end
|
66
|
+
|
67
|
+
def ir_valor_energetico_kcal
|
68
|
+
(@valor_energetico_kcal.round(2) / 2000 * 100).round(2)
|
69
|
+
end
|
70
|
+
|
71
|
+
def ir_grasa_total
|
72
|
+
((@grasas.round(2) + @grasas_saturadas.round(2)) / 70 * 100).round(2)
|
73
|
+
end
|
74
|
+
|
75
|
+
def ir_hidratos_carbono
|
76
|
+
(@hidratos_de_carbono.round(2) /260 * 100).round(2)
|
77
|
+
end
|
78
|
+
|
79
|
+
def ir_azucares
|
80
|
+
(@azucares.round(2) /90 * 100).round(2)
|
81
|
+
end
|
82
|
+
|
83
|
+
def ir_proteinas
|
84
|
+
(@proteinas.round(2) / 50 * 100).round(2)
|
85
|
+
end
|
86
|
+
|
87
|
+
def ir_sal
|
88
|
+
(@sal.round(2) / 6 * 100).round(2)
|
89
|
+
end
|
90
|
+
|
91
|
+
def to_s
|
92
|
+
s1 = "Nombre: #{@nombre}\n"
|
93
|
+
s2 = "Valor energetico kj: #{@valor_energetico_kj}kj\n"
|
94
|
+
s3 = "Valor energetico kcal: #{@valor_energetico_kcal}kcal\n"
|
95
|
+
s4 = "Grasas: #{@grasas}g\n"
|
96
|
+
s5 = "Grasas saturadas: #{@grasas_saturadas}g\n"
|
97
|
+
s6 = "Hidratos de carbono: #{@hidratos_de_carbono}g\n"
|
98
|
+
s7 = "Proteinas: #{@proteinas}g\n"
|
99
|
+
s8 = "Azucares: #{@azucares}g\n"
|
100
|
+
s9 = "Sal: #{@sal}g\n"
|
101
|
+
cadena = s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9
|
102
|
+
return cadena
|
103
|
+
end
|
104
|
+
|
105
|
+
def <=>(other)
|
106
|
+
# los comentarios locales a los métodos no generan documentación
|
107
|
+
return nil unless other.instance_of? Etiqueta
|
108
|
+
@valor_energetico_kcal <=> other.obtener_valor_energetico_kcal
|
109
|
+
end
|
110
|
+
|
111
|
+
def +(other)
|
112
|
+
@valor_energetico_kcal + other.obtener_valor_energetico_kcal
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Individuo
|
2
|
+
|
3
|
+
attr_reader :nombre, :edad, :sexo
|
4
|
+
|
5
|
+
include Comparable
|
6
|
+
|
7
|
+
def initialize(nombre, edad, sexo)
|
8
|
+
@nombre = nombre
|
9
|
+
@edad = edad
|
10
|
+
@sexo = sexo
|
11
|
+
end
|
12
|
+
|
13
|
+
def obtener_nombre
|
14
|
+
@nombre
|
15
|
+
end
|
16
|
+
|
17
|
+
def obtener_edad
|
18
|
+
@edad
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
cadena = ""
|
23
|
+
sexo = ""
|
24
|
+
cadena = cadena + "Nombre: #{@nombre}\n"
|
25
|
+
cadena = cadena + "Edad: #{@edad}\n"
|
26
|
+
if @sexo == 0
|
27
|
+
sexo = "Hombre"
|
28
|
+
else
|
29
|
+
sexo = "Mujer"
|
30
|
+
end
|
31
|
+
cadena = cadena + "Sexo: #{sexo}\n"
|
32
|
+
return cadena
|
33
|
+
end
|
34
|
+
|
35
|
+
def <=>(other)
|
36
|
+
return nil unless other.instance_of? Individuo
|
37
|
+
@edad <=> other.edad
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,198 @@
|
|
1
|
+
Nodo = Struct.new(:value, :next, :prev)
|
2
|
+
|
3
|
+
class ListaEtiquetas
|
4
|
+
|
5
|
+
include Enumerable
|
6
|
+
include Comparable
|
7
|
+
|
8
|
+
def initialize()
|
9
|
+
@inicio = Nodo.new(nil)
|
10
|
+
@fin = Nodo.new(nil)
|
11
|
+
end
|
12
|
+
|
13
|
+
def each
|
14
|
+
nodo = @inicio
|
15
|
+
while (nodo != nil)
|
16
|
+
yield nodo.value
|
17
|
+
nodo = nodo.next
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def pushI(nodo1)
|
22
|
+
nodo = Nodo.new(nodo1, nil, nil)
|
23
|
+
if @inicio.value == nil then
|
24
|
+
@inicio = nodo
|
25
|
+
@fin = nodo
|
26
|
+
else
|
27
|
+
nodo.next = @inicio
|
28
|
+
@inicio.prev = nodo
|
29
|
+
@inicio = nodo
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def pushF(nodo1)
|
34
|
+
nodo = Nodo.new(nodo1, nil, nil)
|
35
|
+
if @inicio.value == nil then
|
36
|
+
@inicio = nodo
|
37
|
+
@fin = nodo
|
38
|
+
else
|
39
|
+
nodo.prev = @fin
|
40
|
+
@fin.next = nodo
|
41
|
+
@fin = nodo
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def popI
|
46
|
+
@inicio = @inicio.next
|
47
|
+
@inicio.prev = nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def popF
|
51
|
+
@fin = @fin.prev
|
52
|
+
@fin.prev = nil
|
53
|
+
end
|
54
|
+
|
55
|
+
def pop(nodo_borrar)
|
56
|
+
|
57
|
+
if (@inicio.next == nil)
|
58
|
+
@inicio = nil
|
59
|
+
else
|
60
|
+
if (nodo_borrar == @inicio)
|
61
|
+
@inicio = @inicio.next
|
62
|
+
@inicio.prev = nil
|
63
|
+
else
|
64
|
+
nodo = @inicio
|
65
|
+
while (nodo != nodo_borrar)
|
66
|
+
nodo = nodo.next
|
67
|
+
end
|
68
|
+
nodo.prev.next = nodo.next
|
69
|
+
if (nodo.next != nil)
|
70
|
+
nodo.next.prev = nodo.prev
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def inicio
|
77
|
+
@inicio.value
|
78
|
+
end
|
79
|
+
|
80
|
+
def fin
|
81
|
+
@fin.value
|
82
|
+
end
|
83
|
+
|
84
|
+
def sal
|
85
|
+
nodo = @inicio
|
86
|
+
suma = 0
|
87
|
+
while (nodo != nil)
|
88
|
+
suma = suma + nodo.value.obtener_sal
|
89
|
+
nodo = nodo.next
|
90
|
+
end
|
91
|
+
return suma
|
92
|
+
end
|
93
|
+
|
94
|
+
def clasificacion_sal
|
95
|
+
if sal <= 0
|
96
|
+
return "Sin sal"
|
97
|
+
elsif sal < 10
|
98
|
+
return "Baja cantidad de sal"
|
99
|
+
elsif sal < 20
|
100
|
+
return "Cantidad moderada de sal"
|
101
|
+
else
|
102
|
+
return "Alta cantidad de sal"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def to_s
|
107
|
+
nodo = @inicio
|
108
|
+
cadena = ""
|
109
|
+
while (nodo != nil)
|
110
|
+
cadena = cadena + nodo.value.obtener_nombre + "\n"
|
111
|
+
nodo = nodo.next
|
112
|
+
end
|
113
|
+
return cadena
|
114
|
+
end
|
115
|
+
|
116
|
+
def posicion(pos)
|
117
|
+
nodo = @inicio
|
118
|
+
pos.times do
|
119
|
+
nodo = nodo.next
|
120
|
+
end
|
121
|
+
return nodo.value
|
122
|
+
end
|
123
|
+
|
124
|
+
def pos(po)
|
125
|
+
nodo = @inicio
|
126
|
+
po.times do
|
127
|
+
nodo = nodo.next
|
128
|
+
end
|
129
|
+
return nodo
|
130
|
+
end
|
131
|
+
|
132
|
+
def valor_energetico
|
133
|
+
calorias_menu = self.reduce(0) { |sum, value| sum + value.obtener_valor_energetico_kcal }
|
134
|
+
return calorias_menu
|
135
|
+
end
|
136
|
+
|
137
|
+
def numero_elementos
|
138
|
+
if @inicio == nil
|
139
|
+
return 0
|
140
|
+
else
|
141
|
+
nodo = @inicio
|
142
|
+
numero = 0
|
143
|
+
while (nodo != nil)
|
144
|
+
numero = numero + 1
|
145
|
+
nodo = nodo.next
|
146
|
+
end
|
147
|
+
return numero
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def ordenar_for
|
152
|
+
@ordenado = self
|
153
|
+
@menor
|
154
|
+
@revisado = [];
|
155
|
+
for i in (0..self.numero_elementos - 1)
|
156
|
+
|
157
|
+
@menor = @ordenado.pos(0)
|
158
|
+
for j in (0..@ordenado.numero_elementos - 1)
|
159
|
+
if (@menor.value.valoracion_nutricional > @ordenado.posicion(j).valoracion_nutricional)
|
160
|
+
@menor = @ordenado.pos(j)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
@ordenado.pop(@menor)
|
164
|
+
@revisado.push(@menor.value)
|
165
|
+
end
|
166
|
+
return @revisado
|
167
|
+
end
|
168
|
+
|
169
|
+
def ordenar_each
|
170
|
+
@revisado = [];
|
171
|
+
self.each do |item|
|
172
|
+
posic = 0
|
173
|
+
if (@revisado.length == 0)
|
174
|
+
@revisado.push(item)
|
175
|
+
elsif (@revisado[@revisado.length - 1] < item)
|
176
|
+
@revisado.push(item)
|
177
|
+
else
|
178
|
+
|
179
|
+
while ((item > @revisado[posic]) && (posic < @revisado.length))
|
180
|
+
posic = posic + 1
|
181
|
+
end
|
182
|
+
@revisado.push(item)
|
183
|
+
tamano = @revisado.length - 1
|
184
|
+
while (tamano >= posic)
|
185
|
+
@revisado[tamano] = @revisado[tamano - 1]
|
186
|
+
tamano = tamano - 1
|
187
|
+
end
|
188
|
+
@revisado[posic] = item
|
189
|
+
|
190
|
+
end
|
191
|
+
end
|
192
|
+
return @revisado
|
193
|
+
end
|
194
|
+
|
195
|
+
def <=>(other)
|
196
|
+
valor_energetico <=> other.valor_energetico
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
class Menu
|
2
|
+
|
3
|
+
include Comparable
|
4
|
+
|
5
|
+
attr_accessor :nombre, :ingesta, :platos
|
6
|
+
|
7
|
+
def initialize(nombre, &block)
|
8
|
+
@nombre = nombre
|
9
|
+
@desayuno = []
|
10
|
+
@almuerzo = []
|
11
|
+
@cena = []
|
12
|
+
|
13
|
+
if block_given?
|
14
|
+
instance_eval(&block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def titulo(str)
|
19
|
+
@title = str
|
20
|
+
end
|
21
|
+
|
22
|
+
def desayuno(des = {})
|
23
|
+
@desayuno << Etiqueta.new(des[:descripcion], des[:grasas], des[:fibra], des[:carbohidratos], 0, des[:proteinas], des[:sal], [des[:porcion], des[:gramos]])
|
24
|
+
end
|
25
|
+
|
26
|
+
def almuerzo(alm = {})
|
27
|
+
@almuerzo << Etiqueta.new(alm[:descripcion], alm[:grasas], alm[:fibra], alm[:carbohidratos], 0, alm[:proteinas], alm[:sal], [alm[:porcion], alm[:gramos]])
|
28
|
+
end
|
29
|
+
|
30
|
+
def cena(cen = {})
|
31
|
+
@cena << Etiqueta.new(cen[:descripcion], cen[:grasas], cen[:fibra], cen[:carbohidratos], 0, cen[:proteinas], cen[:sal], [cen[:porcion], cen[:gramos]])
|
32
|
+
end
|
33
|
+
|
34
|
+
def ingesta(ing = {})
|
35
|
+
@min = ing[:min] if ing[:min]
|
36
|
+
@max = ing[:max] if ing[:max]
|
37
|
+
end
|
38
|
+
|
39
|
+
def kcal
|
40
|
+
300#(@desayuno.reduce(:+) + @almuerzo.reduce(:+) + @cena.reduce(:+)).round(2)
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_s
|
44
|
+
output = Tabla.new
|
45
|
+
output << @nombre
|
46
|
+
output << '' << 'Grasas' << 'Carbohidratos' << 'Proteinas' << 'Fibra' << 'Sal' << 'Valor energético'
|
47
|
+
output << 'Desayuno'
|
48
|
+
@desayuno.each do |des|
|
49
|
+
output << des.obtener_nombre << des.obtener_grasas.to_s << des.obtener_hidratos_carbono.to_s << des.obtener_proteinas.to_s << des.obtener_grasas_saturadas << des.obtener_sal.to_s << des.obtener_valor_energetico_kcal.round(2).to_s
|
50
|
+
end
|
51
|
+
output << ''
|
52
|
+
output << 'Almuerzo'
|
53
|
+
@almuerzo.each do |alm|
|
54
|
+
output << alm.obtener_nombre << alm.obtener_grasas.to_s << alm.obtener_hidratos_carbono.to_s << alm.obtener_proteinas.to_s << alm.obtener_grasas_saturadas << alm.obtener_sal.to_s << alm.obtener_valor_energetico_kcal.round(2).to_s
|
55
|
+
end
|
56
|
+
output << ''
|
57
|
+
output << 'Cena'
|
58
|
+
@cena.each do |cen|
|
59
|
+
output << cen.obtener_nombre << cen.obtener_grasas.to_s << cen.obtener_hidratos_carbono.to_s << cen.obtener_proteinas.to_s << cen.obtener_grasas_saturadas << cen.obtener_sal.to_s << cen.obtener_valor_energetico_kcal.round(2).to_s
|
60
|
+
end
|
61
|
+
output << ''
|
62
|
+
output << 'Valor energético total' << self.kcal
|
63
|
+
return output.to_s
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
class Paciente < Individuo
|
2
|
+
|
3
|
+
attr_reader :nombre, :edad, :sexo, :peso, :altura, :circunferencia_cintura, :circunferencia_cadera, :actividad_fisica
|
4
|
+
|
5
|
+
include Comparable
|
6
|
+
|
7
|
+
|
8
|
+
def initialize(nombre, edad, sexo, peso, altura, circunferencia_cintura, circunferencia_cadera, actividad_fisica)
|
9
|
+
super(nombre, edad, sexo)
|
10
|
+
@peso = peso
|
11
|
+
@altura = altura
|
12
|
+
@circunferencia_cintura = circunferencia_cintura
|
13
|
+
@circunferencia_cadera = circunferencia_cadera
|
14
|
+
@imc = imc
|
15
|
+
@grasa = p_grasa
|
16
|
+
@rcc = rcc
|
17
|
+
@actividad_fisica = actividad_fisica
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def imc
|
22
|
+
@peso / (@altura * @altura)
|
23
|
+
end
|
24
|
+
|
25
|
+
def p_grasa
|
26
|
+
1.2 * @imc + 0.23 * @edad - 10.8 * @sexo - 5.4
|
27
|
+
end
|
28
|
+
|
29
|
+
def rcc
|
30
|
+
(((@circunferencia_cintura[0].round(2) + @circunferencia_cintura[1].round(2)) / 2) / ((@circunferencia_cadera[0].round(2) + @circunferencia_cadera[1].round(2)) / 2).round(2))
|
31
|
+
end
|
32
|
+
|
33
|
+
def clasificacion_oms
|
34
|
+
if (@imc < 18.5)
|
35
|
+
"Bajo peso"
|
36
|
+
elsif (@imc < 24.9)
|
37
|
+
"Adecuado"
|
38
|
+
elsif (@imc < 29.9)
|
39
|
+
"Sobrepeso"
|
40
|
+
elsif (@imc < 34.9)
|
41
|
+
"Obesidad grado 1"
|
42
|
+
elsif (@imc < 39.9)
|
43
|
+
"Obesidad grado 2"
|
44
|
+
else
|
45
|
+
"Obesidad grado 3"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def riesgo
|
50
|
+
if (@sexo == 0) #mujer
|
51
|
+
if (@rcc < 0.75)
|
52
|
+
"Riesgo bajo"
|
53
|
+
elsif (@rcc < 0.82)
|
54
|
+
"Riesgo moderado"
|
55
|
+
else
|
56
|
+
"Riesgo alto"
|
57
|
+
end
|
58
|
+
else #hombre
|
59
|
+
if (@rcc < 0.88)
|
60
|
+
"Riesgo bajo"
|
61
|
+
elsif (@rcc < 0.95)
|
62
|
+
"Riesgo moderado"
|
63
|
+
elsif (@rcc < 1.01)
|
64
|
+
"Riesgo alto"
|
65
|
+
else
|
66
|
+
"Riesgo muy alto"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def obtener_nombre
|
72
|
+
@nombre
|
73
|
+
end
|
74
|
+
|
75
|
+
def to_s
|
76
|
+
cadena = ""
|
77
|
+
cadena = cadena + super.to_s
|
78
|
+
cadena = cadena + "Peso: #{@peso}kg\n"
|
79
|
+
cadena = cadena + "Altura: #{@altura}m\n"
|
80
|
+
cadena = cadena + "Circunferencia cintura: #{@circunferencia_cintura}cm\n"
|
81
|
+
cadena = cadena + "Circunferencia cadera: #{@circunferencia_cadera}cm\n"
|
82
|
+
end
|
83
|
+
|
84
|
+
def <=>(other)
|
85
|
+
return nil unless other.instance_of? Paciente
|
86
|
+
valoracion_nutricional <=> other.valoracion_nutricional
|
87
|
+
end
|
88
|
+
|
89
|
+
def valoracion(menu)
|
90
|
+
|
91
|
+
gasto_energetico_basal = 0
|
92
|
+
if (@sexo == 1) # mujer
|
93
|
+
gasto_energetico_basal = (10 * @peso) + (6.25 * @altura) - (5 * @edad) - 161
|
94
|
+
else # Hombre
|
95
|
+
gasto_energetico_basal = (10 * @peso) + (6.25 * @altura) - (5 * @edad) + 5
|
96
|
+
end
|
97
|
+
|
98
|
+
efecto_termogeno = gasto_energetico_basal * 0.1
|
99
|
+
gasto_actividad_fisica = 0
|
100
|
+
|
101
|
+
if (@actividad_fisica == "reposo")
|
102
|
+
gasto_actividad_fisica = gasto_energetico_basal * 0
|
103
|
+
elsif (@actividad_fisica == "Actividad ligera")
|
104
|
+
gasto_actividad_fisica = gasto_energetico_basal * 0.12
|
105
|
+
elsif (@actividad_fisica == "Actividad moderada")
|
106
|
+
gasto_actividad_fisica = gasto_energetico_basal * 0.27
|
107
|
+
else
|
108
|
+
gasto_actividad_fisica = gasto_energetico_basal * 0.54
|
109
|
+
end
|
110
|
+
|
111
|
+
gasto_energetico_total = gasto_energetico_basal + efecto_termogeno + gasto_actividad_fisica
|
112
|
+
calorias_menu = menu.reduce(0) { |sum, value| sum + value.obtener_valor_energetico_kcal }
|
113
|
+
|
114
|
+
if (gasto_energetico_total < (calorias_menu * 0.9))
|
115
|
+
return true;
|
116
|
+
else
|
117
|
+
return false;
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def valoracion_nutricional
|
122
|
+
|
123
|
+
gasto_energetico_basal = 0
|
124
|
+
if (@sexo == 1) # mujer
|
125
|
+
gasto_energetico_basal = (10 * @peso) + (6.25 * @altura) - (5 * @edad) - 161
|
126
|
+
else # Hombre
|
127
|
+
gasto_energetico_basal = (10 * @peso) + (6.25 * @altura) - (5 * @edad) + 5
|
128
|
+
end
|
129
|
+
|
130
|
+
efecto_termogeno = gasto_energetico_basal * 0.1
|
131
|
+
gasto_actividad_fisica = 0
|
132
|
+
|
133
|
+
if (@actividad_fisica == "reposo")
|
134
|
+
gasto_actividad_fisica = gasto_energetico_basal * 0
|
135
|
+
elsif (@actividad_fisica == "Actividad ligera")
|
136
|
+
gasto_actividad_fisica = gasto_energetico_basal * 0.12
|
137
|
+
elsif (@actividad_fisica == "Actividad moderada")
|
138
|
+
gasto_actividad_fisica = gasto_energetico_basal * 0.27
|
139
|
+
else
|
140
|
+
gasto_actividad_fisica = gasto_energetico_basal * 0.54
|
141
|
+
end
|
142
|
+
|
143
|
+
gasto_energetico_total = gasto_energetico_basal + efecto_termogeno + gasto_actividad_fisica
|
144
|
+
|
145
|
+
return gasto_energetico_total
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|