InformacionNutricional 0.1.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 +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +111 -0
- data/Guardfile +82 -0
- data/InformacionNutricional.gemspec +47 -0
- data/README.md +33 -0
- data/Rakefile +16 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/doc/Etiqueta.html +1389 -0
- data/doc/InformacionNutricional.html +133 -0
- data/doc/InformacionNutricional/Error.html +124 -0
- data/doc/List.html +1300 -0
- data/doc/Node.html +409 -0
- data/doc/Paciente.html +1849 -0
- data/doc/Persona.html +520 -0
- data/doc/_index.html +171 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +496 -0
- data/doc/file.README.html +114 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +114 -0
- data/doc/js/app.js +292 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +555 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/InformacionNutricional.rb +6 -0
- data/lib/InformacionNutricional/array.rb +49 -0
- data/lib/InformacionNutricional/etiqueta.rb +54 -0
- data/lib/InformacionNutricional/list.rb +186 -0
- data/lib/InformacionNutricional/menu.rb +223 -0
- data/lib/InformacionNutricional/paciente.rb +117 -0
- data/lib/InformacionNutricional/persona.rb +32 -0
- data/lib/InformacionNutricional/version.rb +3 -0
- metadata +186 -0
@@ -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
|
+
— 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> »
|
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="InformacionNutricional.html" title="InformacionNutricional (module)">InformacionNutricional</a></span>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Etiqueta.html" title="Etiqueta (class)">Etiqueta</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="Paciente.html" title="Paciente (class)">Paciente</a></span>, <span class='object_link'><a href="Persona.html" title="Persona (class)">Persona</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 Tue Nov 27 20:37:14 2018 by
|
106
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
107
|
+
0.9.16 (ruby-2.5.1).
|
108
|
+
</div>
|
109
|
+
|
110
|
+
</div>
|
111
|
+
</body>
|
112
|
+
</html>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class Array
|
2
|
+
def kcal_for
|
3
|
+
total = 0
|
4
|
+
for i in (0...self.size)
|
5
|
+
total += self[i].calculate_calories
|
6
|
+
end
|
7
|
+
total
|
8
|
+
end
|
9
|
+
def sort_for
|
10
|
+
sorted = [self[0]]
|
11
|
+
for i in (1...self.size)
|
12
|
+
actual = self[i]
|
13
|
+
for j in (0..sorted.size)
|
14
|
+
if (j == sorted.size)
|
15
|
+
sorted.push(actual)
|
16
|
+
elsif (actual.kcal_for < sorted[j].kcal_for)
|
17
|
+
sorted.insert(j, actual)
|
18
|
+
break
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
return sorted
|
23
|
+
end
|
24
|
+
def kcal_each
|
25
|
+
self.collect{|comida| comida.calculate_calories;}.reduce(:+).round(2)
|
26
|
+
end
|
27
|
+
def sort_each
|
28
|
+
sorted = [self[0]]
|
29
|
+
self.each_with_index do |x, pos_x|
|
30
|
+
if (pos_x != 0)
|
31
|
+
sorted.each_with_index do |y, pos_y|
|
32
|
+
if (pos_y == sorted.size-1)
|
33
|
+
if (x.kcal_each < y.kcal_each)
|
34
|
+
sorted.insert(pos_y, x)
|
35
|
+
break
|
36
|
+
else
|
37
|
+
sorted.push(x)
|
38
|
+
break
|
39
|
+
end
|
40
|
+
elsif (x.kcal_each < y.kcal_each)
|
41
|
+
sorted.insert(pos_y, x)
|
42
|
+
break
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
return sorted
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Author:: Ana de Lorenzo-Cáceres Luis (mailto:alu0100972016@ull.edu.es)
|
3
|
+
# Copyright:: Creative Commons
|
4
|
+
# License:: Distributes under the same terms as Ruby
|
5
|
+
|
6
|
+
#Esta clase implementa una etiqueta que almacena el valor nutricional de alimentos
|
7
|
+
#Se ha incluido el mixin Comparable
|
8
|
+
|
9
|
+
class Etiqueta
|
10
|
+
include Comparable
|
11
|
+
|
12
|
+
#Getters de las variables de instancia
|
13
|
+
attr_reader :name, :portions, :n_portions, :portion_size, :fats, :s_fats, :carbs, :sugar, :protein, :salt, :kcal, :kj
|
14
|
+
|
15
|
+
#Se genera la etiqueta con los datos del alimento proporcionados
|
16
|
+
def initialize (name, portions, n_portions, portion_size, fats, s_fats, carbs, sugar, protein, salt)
|
17
|
+
@name, @portions, @n_portions, @portion_size, @fats, @s_fats, @carbs, @sugar, @protein, @salt = name, portions, n_portions, portion_size, fats, s_fats, carbs, sugar, protein, salt
|
18
|
+
end
|
19
|
+
|
20
|
+
#Función que gendetermina las kilocalorías y los kilojulios de los alimentos
|
21
|
+
def calculate_calories
|
22
|
+
@kj = ((@fats * 37) + (@carbs * 17) + (@protein * 17) + (@salt * 28)).round(2)
|
23
|
+
@kcal = ((@fats * 9) + (@carbs * 4) + (@protein * 4) + (@salt * 6)).round(2)
|
24
|
+
end
|
25
|
+
|
26
|
+
#Override del to_s
|
27
|
+
def to_s
|
28
|
+
s = ""
|
29
|
+
if @portions == true
|
30
|
+
s = "(#{@n_portions} porciones; #{@portion_size}g/porcion)"
|
31
|
+
end
|
32
|
+
"#{@name.upcase}#{s}: Por 100g - IR; VALOR ENERGETICO: #{@kcal} kcal/#{@kj} kJ - 2000 kcal/8400 kJ; GRASAS: #{@fats}g - 70g; SATURADAS: #{@s_fats}g - 20g; CARBOHIDRATOS: #{@carbs}g - 260g; AZUCARES: #{@sugar}g - 90g; PROTEINAS: #{@protein}g - 50g; SAL: #{@salt}g - 6g;"
|
33
|
+
end
|
34
|
+
|
35
|
+
#Se define para incluir el mixin Comparable
|
36
|
+
#Se toma como valor para la comparación los kJ
|
37
|
+
#(Valor que devuelve la función calculate_calories)
|
38
|
+
def <=> (other)
|
39
|
+
return nil unless other.is_a?Etiqueta
|
40
|
+
calculate_calories <=> other.calculate_calories
|
41
|
+
end
|
42
|
+
|
43
|
+
#Override del ==
|
44
|
+
#Se toman para considerar iguales: kcal, grasas, carbohidratos,
|
45
|
+
#proteínas y sal
|
46
|
+
def == (other)
|
47
|
+
return nil unless other.is_a?Etiqueta
|
48
|
+
@kcal == other.kcal
|
49
|
+
@fats == other.fats
|
50
|
+
@carbs == other.carbs
|
51
|
+
@protein == other.protein
|
52
|
+
@salt == other.salt
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Author:: Ana de Lorenzo-Cáceres Luis (mailto:alu0100972016@ull.edu.es)
|
3
|
+
# Copyright:: Creative Commons
|
4
|
+
# License:: Distributes under the same terms as Ruby
|
5
|
+
|
6
|
+
#Crea un nodo con :value, :next y :prev
|
7
|
+
Node = Struct.new(:value, :next, :prev)
|
8
|
+
|
9
|
+
#Esta clase implementa una lista doblemente enlazada
|
10
|
+
#Se ha incluido el mixin Enumerable
|
11
|
+
class List
|
12
|
+
include Enumerable
|
13
|
+
|
14
|
+
#Getters de las variables de instancia
|
15
|
+
attr_reader :head, :tail, :size
|
16
|
+
|
17
|
+
#Creamos una lista vacía
|
18
|
+
def initialize
|
19
|
+
@tail = @head = nil
|
20
|
+
@size = 0
|
21
|
+
end
|
22
|
+
|
23
|
+
#Comprueba si la lista está vacía
|
24
|
+
def is_empty
|
25
|
+
empty = ""
|
26
|
+
if (@head == nil)
|
27
|
+
empty = true
|
28
|
+
else
|
29
|
+
empty = false
|
30
|
+
end
|
31
|
+
empty
|
32
|
+
end
|
33
|
+
|
34
|
+
#Método para insertar un nodo por la cabeza
|
35
|
+
def insert_head(node)
|
36
|
+
if is_empty
|
37
|
+
new_node = Node.new(node,nil,nil)
|
38
|
+
@head = new_node
|
39
|
+
@tail = @head
|
40
|
+
else
|
41
|
+
new_node = Node.new(node,@head,nil)
|
42
|
+
@head.prev = new_node
|
43
|
+
@head = new_node
|
44
|
+
end
|
45
|
+
@size = @size + 1
|
46
|
+
end
|
47
|
+
|
48
|
+
#Método para insertar un nodo por la cola
|
49
|
+
def insert_tail(node)
|
50
|
+
if is_empty
|
51
|
+
new_node = Node.new(node,nil,nil)
|
52
|
+
@tail = new_node
|
53
|
+
@head = @tail
|
54
|
+
else
|
55
|
+
new_node = Node.new(node,nil,@tail)
|
56
|
+
@tail.next = new_node
|
57
|
+
@tail = new_node
|
58
|
+
end
|
59
|
+
@size = @size + 1
|
60
|
+
end
|
61
|
+
|
62
|
+
#Método para insertar varios nodos por la cabeza
|
63
|
+
def insert_n_to_head(array)
|
64
|
+
array.each do |node|
|
65
|
+
insert_head(node)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
#Método para insertar varios nodos por la cola
|
70
|
+
def insert_n_to_tail(array)
|
71
|
+
array.each do |node|
|
72
|
+
insert_tail(node)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
#Método para eliminar la cabeza
|
77
|
+
def remove_head
|
78
|
+
if @size == 1
|
79
|
+
@head = nil
|
80
|
+
@tail = @head
|
81
|
+
else
|
82
|
+
@head = @head.next
|
83
|
+
@head.prev = nil
|
84
|
+
end
|
85
|
+
@size = @size - 1
|
86
|
+
end
|
87
|
+
|
88
|
+
#Método para eliminar la cola
|
89
|
+
def remove_tail
|
90
|
+
if @size == 1
|
91
|
+
@tail = nil
|
92
|
+
@head = @tail
|
93
|
+
else
|
94
|
+
@tail = @tail.prev
|
95
|
+
@tail.next = nil
|
96
|
+
end
|
97
|
+
@size = @size - 1
|
98
|
+
end
|
99
|
+
|
100
|
+
#Método para eliminar varios nodos por la cabeza
|
101
|
+
def remove_n_from_head(qty)
|
102
|
+
times = 0
|
103
|
+
while times < qty && @size > 0
|
104
|
+
remove_head
|
105
|
+
times = times + 1
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
#Método para eliminar varios nodos por la cola
|
110
|
+
def remove_n_from_tail(qty)
|
111
|
+
times = 0
|
112
|
+
while times < qty && @size > 0
|
113
|
+
remove_tail
|
114
|
+
times = times + 1
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
#Override del to_s
|
119
|
+
def to_s
|
120
|
+
array = ""
|
121
|
+
node = @head
|
122
|
+
while node != nil
|
123
|
+
array += "#{node.value.name}"
|
124
|
+
if node.next != nil
|
125
|
+
array += ", "
|
126
|
+
end
|
127
|
+
node = node.next
|
128
|
+
end
|
129
|
+
array
|
130
|
+
end
|
131
|
+
|
132
|
+
#Se incluye el método del mixin Enumerable
|
133
|
+
#Se define como una iteración c/u de los calores de los nodos
|
134
|
+
def each
|
135
|
+
aux = @head
|
136
|
+
sz = @size
|
137
|
+
for i in (1..sz)
|
138
|
+
yield aux.value
|
139
|
+
aux = aux.next
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
#Ordena la lista con for
|
144
|
+
def sort_for
|
145
|
+
sorted = [@head.value]
|
146
|
+
aux = @head
|
147
|
+
sz = @size
|
148
|
+
for i in (1...sz)
|
149
|
+
aux = aux.next
|
150
|
+
for j in (0..sorted.size)
|
151
|
+
if (j == sorted.size)
|
152
|
+
sorted.push(aux.value)
|
153
|
+
elsif (aux.value < sorted[j])
|
154
|
+
sorted.insert(j, aux.value)
|
155
|
+
break
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
return sorted
|
160
|
+
end
|
161
|
+
|
162
|
+
#Oredena la lista con each
|
163
|
+
def sort_each
|
164
|
+
sorted = [@head.value]
|
165
|
+
self.each_with_index do |x, pos_x|
|
166
|
+
if (pos_x != 0)
|
167
|
+
sorted.each_with_index do |y, pos_y|
|
168
|
+
if (pos_y == sorted.size - 1)
|
169
|
+
if (x < y)
|
170
|
+
sorted.insert(pos_y, x)
|
171
|
+
break
|
172
|
+
else
|
173
|
+
sorted.push(x)
|
174
|
+
break
|
175
|
+
end
|
176
|
+
elsif (x < y)
|
177
|
+
sorted.insert(pos_y, x)
|
178
|
+
break
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
return sorted
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
@@ -0,0 +1,223 @@
|
|
1
|
+
class Menu
|
2
|
+
|
3
|
+
attr_accessor :nombre, :titulo, :ingesta, :desayuno, :almuerzo, :cena, :total
|
4
|
+
|
5
|
+
def initialize(nombre, &block)
|
6
|
+
@nombre = nombre
|
7
|
+
@titulo = ""
|
8
|
+
@ingesta = []
|
9
|
+
@desayuno = []
|
10
|
+
@almuerzo = []
|
11
|
+
@cena = []
|
12
|
+
@total = 0
|
13
|
+
|
14
|
+
if block_given?
|
15
|
+
if block.arity == 1
|
16
|
+
yield self
|
17
|
+
else
|
18
|
+
instance_eval(&block)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def calculate_calories(grasas, carbs, proteina, sal)
|
24
|
+
kcal = ((grasas.to_f * 9) + (carbs.to_f * 4) + (proteina.to_f * 4) + (sal.to_f * 6)).round(2)
|
25
|
+
@total += kcal
|
26
|
+
kcal
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_s
|
30
|
+
output = @nombre
|
31
|
+
output << "#{' ' * (30 - @nombre.size)} Composición nutricional"
|
32
|
+
output << "\n#{'=' * 120}"
|
33
|
+
output << "\n#{' ' * 30}"
|
34
|
+
output << "grasas".ljust(15)
|
35
|
+
output << "carbs".ljust(15)
|
36
|
+
output << "proteínas".ljust(15)
|
37
|
+
output << "fibra".ljust(15)
|
38
|
+
output << "sal".ljust(15)
|
39
|
+
output << "Kcal".ljust(15)
|
40
|
+
output << "\nDesayuno"
|
41
|
+
@desayuno.each do |comida|
|
42
|
+
output << "\n"
|
43
|
+
comida.each_with_index do |opcion, index|
|
44
|
+
if index == 0
|
45
|
+
name = "#{opcion}"
|
46
|
+
output << "#{opcion} #{' ' * (30-name.size)}"
|
47
|
+
elsif index != 1 && index != 2
|
48
|
+
output << "#{opcion}".ljust(15)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
output << "\n#{'-' * 120}"
|
54
|
+
|
55
|
+
@almuerzo.each do |comida|
|
56
|
+
output << "\n"
|
57
|
+
comida.each_with_index do |opcion, index|
|
58
|
+
if index == 0
|
59
|
+
name = "#{opcion}"
|
60
|
+
output << "#{opcion} #{' ' * (30-name.size)}"
|
61
|
+
elsif index != 1 && index != 2
|
62
|
+
output << "#{opcion}".ljust(15)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
output << "\n#{'-' * 120}"
|
68
|
+
|
69
|
+
@cena.each do |comida|
|
70
|
+
output << "\n"
|
71
|
+
comida.each_with_index do |opcion, index|
|
72
|
+
if index == 0
|
73
|
+
name = "#{opcion}"
|
74
|
+
output << "#{opcion} #{' ' * (30-name.size)}"
|
75
|
+
elsif index != 1 && index != 2
|
76
|
+
output << "#{opcion}".ljust(15)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
output << "\n#{'-' * 120}\n"
|
81
|
+
output << "Kcal totales".ljust(15)
|
82
|
+
output << (@total.round(2)).to_s
|
83
|
+
output
|
84
|
+
end
|
85
|
+
|
86
|
+
def titulo(titulo)
|
87
|
+
@titulo = titulo
|
88
|
+
end
|
89
|
+
|
90
|
+
def ingesta(options = {})
|
91
|
+
ingesta = []
|
92
|
+
ingesta << " #{options[:min]}" if options[:min]
|
93
|
+
ingesta << " #{options[:max]}" if options[:max]
|
94
|
+
@ingesta << ingesta
|
95
|
+
end
|
96
|
+
|
97
|
+
def desayuno(options = {})
|
98
|
+
desayuno = []
|
99
|
+
desayuno << " #{options[:descripcion]}" if options[:descripcion]
|
100
|
+
if options[:porcion]
|
101
|
+
desayuno << " #{options[:porcion]}"
|
102
|
+
else
|
103
|
+
desayuno << " 0"
|
104
|
+
end
|
105
|
+
if options[:gramos]
|
106
|
+
desayuno << " #{options[:gramos]}"
|
107
|
+
else
|
108
|
+
desayuno << " 0"
|
109
|
+
end
|
110
|
+
if options[:grasas]
|
111
|
+
desayuno << " #{options[:grasas]}"
|
112
|
+
else
|
113
|
+
desayuno << " 0"
|
114
|
+
end
|
115
|
+
if options[:carbohidratos]
|
116
|
+
desayuno << " #{options[:carbohidratos]}"
|
117
|
+
else
|
118
|
+
desayuno << " 0"
|
119
|
+
end
|
120
|
+
if options[:proteinas]
|
121
|
+
desayuno << " #{options[:proteinas]}"
|
122
|
+
else
|
123
|
+
desayuno << " 0"
|
124
|
+
end
|
125
|
+
if options[:fibra]
|
126
|
+
desayuno << " #{options[:fibra]}"
|
127
|
+
else
|
128
|
+
desayuno << " 0"
|
129
|
+
end
|
130
|
+
if options[:sal]
|
131
|
+
desayuno << " #{options[:sal]}"
|
132
|
+
else
|
133
|
+
desayuno << " 0"
|
134
|
+
end
|
135
|
+
desayuno << calculate_calories(options[:grasas], options[:carbohidratos], options[:proteina], options[:sal])
|
136
|
+
@desayuno << desayuno
|
137
|
+
end
|
138
|
+
|
139
|
+
def almuerzo(options = {})
|
140
|
+
almuerzo = []
|
141
|
+
almuerzo << " #{options[:descripcion]}" if options[:descripcion]
|
142
|
+
if options[:porcion]
|
143
|
+
almuerzo << " #{options[:porcion]}"
|
144
|
+
else
|
145
|
+
almuerzo << " 0"
|
146
|
+
end
|
147
|
+
if options[:gramos]
|
148
|
+
almuerzo << " #{options[:gramos]}"
|
149
|
+
else
|
150
|
+
almuerzo << " 0"
|
151
|
+
end
|
152
|
+
if options[:grasas]
|
153
|
+
almuerzo << " #{options[:grasas]}"
|
154
|
+
else
|
155
|
+
almuerzo << " 0"
|
156
|
+
end
|
157
|
+
if options[:carbohidratos]
|
158
|
+
almuerzo << " #{options[:carbohidratos]}"
|
159
|
+
else
|
160
|
+
almuerzo << " 0"
|
161
|
+
end
|
162
|
+
if options[:proteinas]
|
163
|
+
almuerzo << " #{options[:proteinas]}"
|
164
|
+
else
|
165
|
+
almuerzo << " 0"
|
166
|
+
end
|
167
|
+
if options[:fibra]
|
168
|
+
almuerzo << " #{options[:fibra]}"
|
169
|
+
else
|
170
|
+
almuerzo << " 0"
|
171
|
+
end
|
172
|
+
if options[:sal]
|
173
|
+
almuerzo << " #{options[:sal]}"
|
174
|
+
else
|
175
|
+
almuerzo << " 0"
|
176
|
+
end
|
177
|
+
almuerzo << calculate_calories(options[:grasas], options[:carbohidratos], options[:proteina], options[:sal])
|
178
|
+
@almuerzo << almuerzo
|
179
|
+
end
|
180
|
+
|
181
|
+
def cena(options = {})
|
182
|
+
cena = []
|
183
|
+
cena << " #{options[:descripcion]}" if options[:descripcion]
|
184
|
+
if options[:porcion]
|
185
|
+
cena << " #{options[:porcion]}"
|
186
|
+
else
|
187
|
+
cena << " 0"
|
188
|
+
end
|
189
|
+
if options[:gramos]
|
190
|
+
cena << " #{options[:gramos]}"
|
191
|
+
else
|
192
|
+
cena << " 0"
|
193
|
+
end
|
194
|
+
if options[:grasas]
|
195
|
+
cena << " #{options[:grasas]}"
|
196
|
+
else
|
197
|
+
cena << " 0"
|
198
|
+
end
|
199
|
+
if options[:carbohidratos]
|
200
|
+
cena << " #{options[:carbohidratos]}"
|
201
|
+
else
|
202
|
+
cena << " 0"
|
203
|
+
end
|
204
|
+
if options[:proteinas]
|
205
|
+
cena << " #{options[:proteinas]}"
|
206
|
+
else
|
207
|
+
cena << " 0"
|
208
|
+
end
|
209
|
+
if options[:fibra]
|
210
|
+
cena << " #{options[:fibra]}"
|
211
|
+
else
|
212
|
+
cena << " 0"
|
213
|
+
end
|
214
|
+
if options[:sal]
|
215
|
+
cena << " #{options[:sal]}"
|
216
|
+
else
|
217
|
+
cena << " 0"
|
218
|
+
end
|
219
|
+
cena << calculate_calories(options[:grasas], options[:carbohidratos], options[:proteina], options[:sal])
|
220
|
+
@cena << cena
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|