InforNutricional 0.1.1

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,112 @@
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.16
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
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="InforNutricional.html" title="InforNutricional (module)">InforNutricional</a></span>
86
+
87
+
88
+
89
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Individuo.html" title="Individuo (class)">Individuo</a></span>, <span class='object_link'><a href="List.html" title="List (class)">List</a></span>, <span class='object_link'><a href="Node.html" title="Node (class)">Node</a></span>, <span class='object_link'><a href="Nutricion.html" title="Nutricion (class)">Nutricion</a></span>, <span class='object_link'><a href="Paciente.html" title="Paciente (class)">Paciente</a></span>
90
+
91
+
92
+ </p>
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+ </div>
103
+
104
+ <div id="footer">
105
+ Generated on Wed Dec 12 19:13:39 2018 by
106
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
107
+ 0.9.16 (ruby-2.3.4).
108
+ </div>
109
+
110
+ </div>
111
+ </body>
112
+ </html>
@@ -0,0 +1,9 @@
1
+ require "InforNutricional/version"
2
+ require "InforNutricional/CodeInforNutricional"
3
+ require "InforNutricional/CodeDList.rb"
4
+ require "InforNutricional/icc.rb"
5
+ require "InforNutricional/array.rb"
6
+ require "InforNutricional/dsl.rb"
7
+ module InforNutricional
8
+ # Your code goes here...
9
+ end
@@ -0,0 +1,182 @@
1
+
2
+
3
+ #Create a Struct with :value, :next and :prev
4
+ Node = Struct.new(:value, :next, :prev) #Nodo
5
+
6
+ # Clase List que representa una lista doblemente enlazada
7
+ class List
8
+
9
+ attr_reader :head, :tail
10
+
11
+ # Incluimos el módulo mixin Enumerable
12
+ include Enumerable
13
+
14
+ # Metodo initialize de la clase
15
+ def initializate()
16
+ @tail = @head = nil
17
+ end
18
+
19
+ # Método para enumerar lista
20
+ def each
21
+ nodo = @head
22
+ while(nodo != nil)
23
+ yield nodo.value
24
+ nodo = nodo.prev
25
+ end
26
+ end
27
+
28
+ ################################################################################
29
+ #______________________________________________________________________________#
30
+
31
+ #Método para ordenar una lista pasandola a array empleando el for
32
+ def ordenar_For ()
33
+ lista = self.map { |x| x}
34
+ for i in 0..(lista.length) do
35
+ for j in 0..(lista.length-2) do
36
+ if(lista[j] > lista[j+1])
37
+ temp = lista[j]
38
+ lista[j] = lista[j+1]
39
+ lista[j+1] = temp
40
+ end
41
+ end
42
+ end
43
+ lista
44
+ end
45
+
46
+ ################################################################################
47
+ #______________________________________________________________________________#
48
+
49
+ def ordenar_Each ()
50
+ lista = self.map { |x| x}
51
+ indice = 0
52
+ lista.each do |x|
53
+ lista.each do |y|
54
+ if (indice < lista.length-1)
55
+ if (lista[indice] > lista[indice+1])
56
+ temp = lista[indice]
57
+ lista[indice] = lista[indice+1]
58
+ lista[indice+1] = temp
59
+ end
60
+ end
61
+ indice = indice+1
62
+ end
63
+ indice = 0
64
+ end
65
+ lista
66
+ end
67
+
68
+ ################################################################################
69
+ #______________________________________________________________________________#
70
+
71
+ # Método que comprueba si la lista está vacía
72
+ def empty?()
73
+ if (@tail != nil and @head != nil)
74
+ return false
75
+ else
76
+ return true
77
+ end
78
+ end
79
+
80
+ ################################################################################
81
+ #______________________________________________________________________________#
82
+
83
+ # Método para mostrar la lista
84
+ def to_s
85
+
86
+ if (@head != nil)
87
+ node_aux = @head
88
+ @output = node_aux.value
89
+
90
+ if ( node_aux.prev != nil )
91
+ @output += " "
92
+ end
93
+
94
+ while (node_aux.prev != nil) do
95
+ node_aux = node_aux.prev
96
+ @output += node_aux.value
97
+
98
+ if ( node_aux.prev != nil )
99
+ @output += " "
100
+ end
101
+ end
102
+
103
+ "Lista: #{@output}"
104
+ end
105
+ end
106
+
107
+
108
+ ################################################################################
109
+ #______________________________________________________________________________#
110
+
111
+ # Método para introducir un elemento por la cabeza en la lista
112
+ def insert_head(value)
113
+
114
+ node = Node.new(value)
115
+
116
+ if (@head == nil)
117
+ @head = @tail = node
118
+ else
119
+ node.prev = @head
120
+ @head.next = node
121
+ @head = node
122
+ end
123
+
124
+ end
125
+
126
+ #______________________________________________________________________________#
127
+
128
+ # Método para introducir un elemento por la cola en la lista
129
+ def insert_tail(value)
130
+
131
+ node = Node.new(value)
132
+
133
+ if (@tail == nil)
134
+ @head = @tail = node
135
+ else
136
+ node.next = @tail
137
+ @tail.prev = node
138
+ @tail = node
139
+ end
140
+
141
+ end
142
+
143
+ ################################################################################
144
+ ################################################################################
145
+
146
+ # Método para extraer un elemento por la cabeza en la lista
147
+ def extract_head()
148
+
149
+ node = @head
150
+ @head = @head.prev
151
+
152
+ if (@head == nil)
153
+ @tail = nil
154
+ else
155
+ @head.next = nil
156
+ end
157
+
158
+ node.prev = nil
159
+ node.next =nil
160
+
161
+ return node.value
162
+ end
163
+
164
+ #______________________________________________________________________________#
165
+ # Método para extraer un elemento por la cola en la lista
166
+ def extract_tail()
167
+
168
+ node = @tail
169
+ @tail = @tail.next
170
+
171
+ if (@tail == nil)
172
+ @head = nil
173
+ else
174
+ @tail.prev = nil
175
+ end
176
+
177
+ node.prev = nil
178
+ node.next =nil
179
+ return node.value
180
+ end
181
+
182
+ end
@@ -0,0 +1,173 @@
1
+ # Clase que calcula la información nutricional de una etiqueta
2
+ class Nutricion
3
+
4
+ attr_reader :nombre_alimento, :grasas, :saturadas, :monoinsaturadas, :polinsaturadas, :hidratos, :azucares, :polialcoholes, :almidon, :fibra, :proteinas, :sal, :vitaminas, :minerales, :kcal, :kj
5
+
6
+ #Módulo para comparar (mixin)
7
+ include Comparable
8
+ # Método initialize de la clase.
9
+ def initialize(nombre_alimento, saturadas, monoinsaturadas, polinsaturadas, azucares, polialcoholes, almidon, fibra, proteinas, sal, vitaminas, minerales)
10
+ # Variables de instancia
11
+ @nombre_alimento = nombre_alimento
12
+ @saturadas = saturadas
13
+ @monoinsaturadas = monoinsaturadas
14
+ @polinsaturadas = polinsaturadas
15
+ @azucares = azucares
16
+ @polialcoholes = polialcoholes
17
+ @almidon = almidon
18
+ @fibra = fibra
19
+ @proteinas = proteinas
20
+ @sal = sal
21
+ @vitaminas = vitaminas
22
+ @minerales = minerales
23
+
24
+ #Métodos
25
+ calculo_grasas()
26
+ calculo_hidratos()
27
+
28
+ calculo_almidon()
29
+ calculo_azucares()
30
+ calculo_fibra()
31
+ calculo_monoinsaturadas()
32
+ calculo_polialcoholes()
33
+ calculo_polinsaturadas()
34
+ calculo_proteinas()
35
+ calculo_sal()
36
+ calculo_saturadas()
37
+
38
+ calculo_kj()
39
+ calculo_kcal()
40
+
41
+ calculo_ir()
42
+
43
+ to_s()
44
+
45
+
46
+
47
+ end
48
+
49
+ # Definición de los métodos
50
+ # Método para comparar dos objetos
51
+ def <=>(other)
52
+ return nil unless other.instance_of?Nutricion
53
+ @kcal <=> other.kcal
54
+ end
55
+
56
+ def +(other)
57
+ return nil unless other.instance_of?Nutricion
58
+ Nutricion.new(nombre_alimento + other.nombre_alimento,
59
+ saturadas + other.saturadas,
60
+ monoinsaturadas + other.monoinsaturadas,
61
+ polinsaturadas + other.polinsaturadas,
62
+ azucares + other.azucares,
63
+ polialcoholes + other.polialcoholes,
64
+ almidon + other.almidon,
65
+ fibra + other.fibra,
66
+ proteinas + other.proteinas,
67
+ sal + other.sal,
68
+ vitaminas + other.vitaminas,
69
+ minerales + other.minerales)
70
+ end
71
+
72
+ # Método para calcular las grasas totales.
73
+ def calculo_grasas()
74
+ @grasas = @saturadas + @monoinsaturadas + @polinsaturadas
75
+ @grasas = @grasas.round(2)
76
+ end
77
+
78
+ # Método para calcular los hidratos totales.
79
+ def calculo_hidratos()
80
+ @hidratos = @azucares + @polialcoholes + @almidon
81
+ @hidratos = @hidratos.round(2)
82
+ end
83
+
84
+ # Método para calcular kcal y kj de las grasas saturadas.
85
+ def calculo_saturadas()
86
+ @kcal_saturadas = @saturadas*9
87
+ @kj_saturadas = @saturadas*37
88
+ end
89
+
90
+ # Método para calcular kcal y kj de las grasas monoinsaturadas.
91
+ def calculo_monoinsaturadas()
92
+ @kcal_monoinsaturadas = @monoinsaturadas*9
93
+ @kj_monoinsaturadas = @monoinsaturadas*37
94
+ end
95
+
96
+ # Método para calcular kcal y kj de las grasas polinsaturadas.
97
+ def calculo_polinsaturadas()
98
+ @kcal_polinsaturadas = @polinsaturadas*9
99
+ @kj_polinsaturadas = @polinsaturadas*37
100
+ end
101
+
102
+ # Método para calcular kcal y kj de los azúcares
103
+ def calculo_azucares()
104
+ @kcal_azucares = @azucares*4
105
+ @kj_azucares = @azucares*17
106
+ end
107
+
108
+ # Método para calcular kcal y kj de los polialcoholes.
109
+ def calculo_polialcoholes()
110
+ @kcal_polialcoholes = @polialcoholes * 2.4
111
+ @kj_polialcoholes = @polialcoholes * 10
112
+ end
113
+
114
+ # Método para calcular kcal y kj del almidón.
115
+ def calculo_almidon()
116
+ @kcal_almidon = @almidon * 4
117
+ @kj_almidon = @almidon * 17
118
+ end
119
+
120
+ # Método para calcular kcal y kj de la fibra.
121
+ def calculo_fibra()
122
+ @kcal_fibra = @fibra*2
123
+ @kj_fibra = @fibra*8
124
+ end
125
+
126
+ # Método para calcular kcal y kj de las proteínas.
127
+ def calculo_proteinas()
128
+ @kcal_proteinas = @proteinas*4
129
+ @kj_proteinas = @proteinas*17
130
+ end
131
+
132
+ # Método para calcular kcal y kj de la sal.
133
+ def calculo_sal()
134
+ @kcal_sal = @sal*6
135
+ @kj_sal = @sal*25
136
+ end
137
+
138
+
139
+ # Método para calcular kj totales del alimento.
140
+ def calculo_kj()
141
+ @kj = @kj_almidon + @kj_azucares + @kj_fibra + @kj_sal + @kj_monoinsaturadas + @kj_polialcoholes + @kj_polinsaturadas + @kj_proteinas + @kj_saturadas
142
+ @kj = @kj.round(2)
143
+
144
+ end
145
+
146
+ # Método para calcular kcal totales del alimento.
147
+ def calculo_kcal()
148
+ @kcal = @kcal_almidon + @kcal_azucares + @kcal_fibra + @kcal_sal + @kcal_monoinsaturadas + @kcal_polialcoholes + @kcal_polinsaturadas + @kcal_proteinas + @kcal_saturadas
149
+ @kcal = @kcal.round(2)
150
+ end
151
+
152
+ # Método para calcular la ingesta recomendada.
153
+ def calculo_ir()
154
+ @ir_kj = ( (@kj*100)/8400 ).round(2)
155
+ @ir_kcal = ( (@kcal*100)/2000 ).round(2)
156
+ @ir_grasas = ( (@grasas*100)/70 ).round(2)
157
+ @ir_saturadas = ( (@saturadas*100)/20 ).round(2)
158
+ @ir_hidratos = ( (@hidratos*100)/260 ).round(2)
159
+ @ir_azucares = ( (@azucares*100)/90 ).round(2)
160
+ @ir_proteinas = ( (@proteinas*100)/50 ).round(2)
161
+ @ir_sal = ( (@sal*100)/6 ).round(2)
162
+ #vr_minerales?
163
+ #vr_vitaminas?
164
+ end
165
+
166
+ # Método para mostrar los datos del alimento.
167
+ def to_s()
168
+ "El alimento es #{@nombre_alimento}. \nValor energético: #{@kcal} kcal /#{@kj} kj | % INGESTA RECOMENDADA: #{@ir_kcal}% / #{@ir_kj}% \nGrasas: #{@grasas} | % INGESTA RECOMENDADA: #{@ir_grasas}%, de las cuales: \n Saturadas: #{@saturadas} gramos. | % INGESTA RECOMENDADA: #{@ir_saturadas}% \n Monoinsaturadas: #{@monoinsaturadas} gramos. \n Polinsaturadas: #{@polinsaturadas} gramos. \nHidratos de carbono: #{@hidratos} gramos. | % INGESTA RECOMENDADA: #{@ir_hidratos}%, de los cuales: \n Azucares: #{@azucares} gramos. | % INGESTA RECOMENDADA: #{@ir_azucares}% \n Polialcoholes: #{@polialcoholes} gramos. \n Almidon: #{@almidon} gramos.n \nFibra alimentaria: #{@fibra} gramos. \nProteinas: #{@proteinas} gramos. | % INGESTA RECOMENDADA: #{@ir_proteinas}% \nSal: #{@sal} gramos | % INGESTA RECOMENDADA: #{@ir_sal}% \nVitaminas: #{@vitaminas} miligramos. \nMinerales: #{@minerales} miligramos."
169
+
170
+ end
171
+
172
+
173
+ end