gema-alu0101040882 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 +8 -0
- data/.rake_tasks~ +7 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/.yardoc/checksums +9 -0
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +111 -0
- data/Guardfile +82 -0
- data/README.md +32 -0
- data/Rakefile +8 -0
- data/bin/bundle +105 -0
- data/bin/console +14 -0
- data/bin/htmldiff +29 -0
- data/bin/ldiff +29 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/bin/setup +8 -0
- data/doc/Dll.html +1502 -0
- data/doc/Dll/Node.html +398 -0
- data/doc/Etiqueta_nut.html +1717 -0
- data/doc/Gema.html +134 -0
- data/doc/Individuo.html +289 -0
- data/doc/Menu_dietetico.html +483 -0
- data/doc/Paciente.html +233 -0
- data/doc/Paciente_obeso.html +1386 -0
- data/doc/Valores_nut.html +777 -0
- data/doc/_index.html +208 -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 +115 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +115 -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 +651 -0
- data/doc/top-level-namespace.html +112 -0
- data/gema.gemspec +43 -0
- data/lib/gema.rb +14 -0
- data/lib/gema/etiqueta_nut.rb +46 -0
- data/lib/gema/individuo.rb +14 -0
- data/lib/gema/list.rb +212 -0
- data/lib/gema/menu.rb +134 -0
- data/lib/gema/menu_dietetico.rb +37 -0
- data/lib/gema/paciente.rb +12 -0
- data/lib/gema/paciente_obeso.rb +75 -0
- data/lib/gema/valores_nut.rb +40 -0
- data/lib/gema/version.rb +4 -0
- metadata +197 -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="Gema.html" title="Gema (module)">Gema</a></span>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Dll.html" title="Dll (class)">Dll</a></span>, <span class='object_link'><a href="Etiqueta_nut.html" title="Etiqueta_nut (class)">Etiqueta_nut</a></span>, <span class='object_link'><a href="Individuo.html" title="Individuo (class)">Individuo</a></span>, <span class='object_link'><a href="Menu_dietetico.html" title="Menu_dietetico (class)">Menu_dietetico</a></span>, <span class='object_link'><a href="Paciente.html" title="Paciente (class)">Paciente</a></span>, <span class='object_link'><a href="Paciente_obeso.html" title="Paciente_obeso (class)">Paciente_obeso</a></span>, <span class='object_link'><a href="Valores_nut.html" title="Valores_nut (class)">Valores_nut</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 19 11:49:27 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>
|
data/gema.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "gema/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gema-alu0101040882"
|
8
|
+
spec.version = Gema::VERSION
|
9
|
+
spec.authors = ["Daniel Suarez"]
|
10
|
+
spec.email = ["alu0101040882@ull.edu.es"]
|
11
|
+
|
12
|
+
spec.summary = %q{Etiqueta de información nutricional}
|
13
|
+
spec.description = %q{Esta es una gema que muestra la información nutricional}
|
14
|
+
spec.homepage = "https://github.com/ULL-ESIT-LPP-1819/tdd-alu0101040882"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
# if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
20
|
+
#else
|
21
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
# "public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
# Specify which files should be added to the gem when it is released.
|
26
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
27
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
28
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
29
|
+
end
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
36
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
37
|
+
spec.add_development_dependency "guard"
|
38
|
+
spec.add_development_dependency "guard-rspec"
|
39
|
+
spec.add_development_dependency "guard-bundler"
|
40
|
+
|
41
|
+
spec.add_development_dependency "coveralls"
|
42
|
+
|
43
|
+
end
|
data/lib/gema.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "gema/version"
|
2
|
+
require "gema/etiqueta_nut"
|
3
|
+
require "gema/list.rb"
|
4
|
+
require "gema/valores_nut.rb"
|
5
|
+
require "gema/individuo.rb"
|
6
|
+
require "gema/paciente.rb"
|
7
|
+
require "gema/paciente_obeso.rb"
|
8
|
+
require "gema/menu_dietetico.rb"
|
9
|
+
require 'benchmark'
|
10
|
+
require "gema/menu.rb"
|
11
|
+
|
12
|
+
module Gema
|
13
|
+
# Your code goes here...
|
14
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#Etiqueta nutricional de un individuo
|
2
|
+
class Etiqueta_nut
|
3
|
+
|
4
|
+
include Comparable
|
5
|
+
|
6
|
+
attr_reader :kj, :kcal, :nombre, :grasas, :grasas_s, :hidratos, :azucares, :proteinas, :sal, :grasas_mon, :grasas_pol, :polialcoholes, :almidon, :fibra, :vitaminas, :minerales, :n_porciones, :tamaño
|
7
|
+
|
8
|
+
|
9
|
+
def initialize(nombre,grasas,grasas_s,hidratos,azucares,proteinas,sal,grasas_mon,grasas_pol,polialcoholes,almidon,fibra,vitaminas,minerales)
|
10
|
+
@nombre,@grasas,@grasas_s,@hidratos,@azucares,@proteinas,@sal,@grasas_mon,@grasas_pol,@polialcoholes,@almidon,@fibra,@vitaminas,@minerales = nombre,grasas,grasas_s,hidratos,azucares,proteinas,sal,grasas_mon,grasas_pol,polialcoholes,almidon,fibra,vitaminas,minerales
|
11
|
+
end
|
12
|
+
|
13
|
+
#Añade la porciones y el tamaño a la etiqueta
|
14
|
+
def porciones(n_porciones,tamaño)
|
15
|
+
@n_porciones,@tamaño = n_porciones,tamaño
|
16
|
+
end
|
17
|
+
|
18
|
+
#Calcula el valor energetico de una etiqueta
|
19
|
+
def valor_energetico()
|
20
|
+
@kj = @grasas*37 + @grasas_s*37 + @hidratos*17 + @azucares*81 + @proteinas*50 + @sal*25 + @grasas_mon*37 + @grasas_pol*37 + @polialcoholes*10 + @almidon*17 + @fibra * 8 + @minerales*5
|
21
|
+
@kcal = @grasas*9 + @grasas_s*9 + @hidratos*4 + @azucares*19 + @proteinas*4 + @sal*6 + @grasas_mon*9 + @grasas_pol*9 + @polialcoholes*2.4 + @almidon*4 + @fibra*2 + @minerales*2
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s()
|
26
|
+
|
27
|
+
"#{@nombre}".ljust(24) + "#{@grasas}\t#{@hidratos}\t\t#{@azucares}\t\t#{@proteinas}\t\t#{@sal}\t#{@polialcoholes}\t\t#{@almidon}\t#{@fibra}\t#{@vitaminas}\t\t#{@minerales}\t\t#{@kcal}"
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
#Convierte la etiqueta a una cadena
|
32
|
+
def to_s_()
|
33
|
+
"Nombre:#{@nombre}\nGrasas:#{@grasas}\nGrasas Saturadas:#{@grasas_s}\nHidratos:#{@hidratos}\nAzúcares:#{@azucares}\nNombre:#{@proteinas}\nSal:#{@sal}\nGrasas Monoinsaturasas:#{@grasas_mon}\nGrasas Polisaturadas:#{@grasas_pol}\nPolialcoholes:#{@polialcoholes}\nAlmidon:#{@almidon}\nFibra:#{@fibra}\nVitaminas:#{@vitaminas}\nMinerales:#{@minerales}\nEnergía (Kj):#{@kj}\nEnergía (Kcal):#{@kcal}\n"
|
34
|
+
end
|
35
|
+
|
36
|
+
#Convierte la etiqueta a una cadena comoun porcentaje
|
37
|
+
def to_s_porcentaje()
|
38
|
+
"Nombre:#{@nombre}\nGrasas:#{@grasas/100.0}\nGrasas Saturadas:#{@grasas_s/100.0}\nHidratos:#{@hidratos/100.0}\nAzúcares:#{@azucares/100.0}\nNombre:#{@proteinas/100.0}\nSal:#{@sal/100.0}\nGrasas Monoinsaturasas:#{@grasas_mon/100.0}\nGrasas Polisaturadas:#{@grasas_pol/100.0}\nPolialcoholes:#{@polialcoholes/100.0}\nAlmidon:#{@almidon/100.0}\nFibra:#{@fibra/100.0}\nVitaminas:#{@vitaminas/100.0}\nMinerales:#{@minerales/100.0}\nEnergía (Kj):#{@kj/100.0}\nEnergía (Kcal):#{@kcal/100.0}\nVALORES DE REFERENCIA:\nValor energético:8.400kJ/ 2000kcal/g\nGrasa total: 70g\nAcidos grasos saturados: 20g\nHidratos de carbono: 260g\nAzúcares: 90g\nProteínas: 50g\nSal: 6g\n"
|
39
|
+
end
|
40
|
+
|
41
|
+
#Metodo de comparaciones utilizado para el modulo comparable
|
42
|
+
def <=> (other)
|
43
|
+
self.nombre <=> other.nombre
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
data/lib/gema/list.rb
ADDED
@@ -0,0 +1,212 @@
|
|
1
|
+
#Lista doblemente enlazada
|
2
|
+
class Dll
|
3
|
+
include Enumerable
|
4
|
+
attr_accessor :head, :tail, :size
|
5
|
+
|
6
|
+
Node = Struct.new( :value, :next, :prev)
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@head = nil
|
10
|
+
@tail = nil
|
11
|
+
@size = 0
|
12
|
+
end
|
13
|
+
|
14
|
+
#Comprueba si la lista esta vacía
|
15
|
+
def empty
|
16
|
+
@size == 0
|
17
|
+
end
|
18
|
+
|
19
|
+
#Inserta por la cabeza
|
20
|
+
def insert_head(value)
|
21
|
+
|
22
|
+
if empty()
|
23
|
+
@head = Node.new(value,nil,nil)
|
24
|
+
@tail = @head
|
25
|
+
else
|
26
|
+
@head.prev = Node.new(value,@head,nil)
|
27
|
+
@head = @head.prev;
|
28
|
+
end
|
29
|
+
|
30
|
+
@size = @size + 1
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
#Inserta por la cola
|
35
|
+
def insert_tail(value)
|
36
|
+
|
37
|
+
if empty()
|
38
|
+
@head = Node.new(value,nil,nil)
|
39
|
+
@tail = @head
|
40
|
+
else
|
41
|
+
@tail.next = Node.new(value,nil,@tail)
|
42
|
+
@tail = @tail.next;
|
43
|
+
end
|
44
|
+
|
45
|
+
@size = @size + 1
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
#Extrae por la cabeza
|
50
|
+
def extract_head
|
51
|
+
|
52
|
+
aux = @head
|
53
|
+
@head = @head.next
|
54
|
+
|
55
|
+
if @head != nil
|
56
|
+
@tail.next = nil
|
57
|
+
else
|
58
|
+
@tail = nil
|
59
|
+
end
|
60
|
+
|
61
|
+
aux.next = nil
|
62
|
+
aux.prev = nil
|
63
|
+
|
64
|
+
@size = @size - 1
|
65
|
+
return aux
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
#Extrae por la cola
|
70
|
+
def extract_tail
|
71
|
+
|
72
|
+
aux = @tail
|
73
|
+
@tail = @tail.prev
|
74
|
+
|
75
|
+
if @tail != nil
|
76
|
+
@tail.next = nil
|
77
|
+
else
|
78
|
+
@head = nil
|
79
|
+
end
|
80
|
+
|
81
|
+
aux.next = nil
|
82
|
+
aux.prev = nil
|
83
|
+
|
84
|
+
@size = @size - 1
|
85
|
+
return aux
|
86
|
+
end
|
87
|
+
|
88
|
+
#Imprime la lista
|
89
|
+
def print
|
90
|
+
aux = @head
|
91
|
+
|
92
|
+
while aux != nil do
|
93
|
+
puts aux.value.to_s
|
94
|
+
aux = aux.next
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
#Imprime la lista a la inversa
|
99
|
+
def reverse_print
|
100
|
+
aux = @tail
|
101
|
+
|
102
|
+
while aux != nil do
|
103
|
+
puts aux.value.to_s
|
104
|
+
aux = aux.prev
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
#Obtiene el elemento en la posicion n
|
109
|
+
def get(n)
|
110
|
+
i = 0
|
111
|
+
aux = @head
|
112
|
+
while i < n do
|
113
|
+
aux = aux.next
|
114
|
+
i += 1
|
115
|
+
end
|
116
|
+
|
117
|
+
return aux
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
#Elimina el elemento al que corresponda value
|
123
|
+
def remove(value)
|
124
|
+
|
125
|
+
node = @head
|
126
|
+
while node.value.sal != value do
|
127
|
+
node = node.next
|
128
|
+
end
|
129
|
+
|
130
|
+
if node != nil
|
131
|
+
|
132
|
+
if node != @head
|
133
|
+
node.prev.next = node.next
|
134
|
+
else
|
135
|
+
@head = node.next
|
136
|
+
end
|
137
|
+
|
138
|
+
if node != @tail
|
139
|
+
node.next.prev = node.prev
|
140
|
+
else
|
141
|
+
@tail = node.prev
|
142
|
+
end
|
143
|
+
|
144
|
+
@size-=1
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
#Clasifica usando la sal
|
151
|
+
def clasify_salt
|
152
|
+
|
153
|
+
i = 0
|
154
|
+
sz = @size
|
155
|
+
|
156
|
+
sorted_dll = Dll.new()
|
157
|
+
|
158
|
+
while i < sz do
|
159
|
+
aux = @head
|
160
|
+
min = aux.value
|
161
|
+
|
162
|
+
while aux != nil do
|
163
|
+
if aux.value.sal < min.sal
|
164
|
+
min = aux.value
|
165
|
+
end
|
166
|
+
|
167
|
+
aux = aux.next
|
168
|
+
end
|
169
|
+
|
170
|
+
sorted_dll.insert_tail(min)
|
171
|
+
remove(min.sal)
|
172
|
+
i+=1
|
173
|
+
end
|
174
|
+
|
175
|
+
return sorted_dll
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
#Clasifica usando la sal con el metodo de la burbuja
|
180
|
+
def salt_bubble
|
181
|
+
i = 1
|
182
|
+
|
183
|
+
while i < @size
|
184
|
+
j = 0
|
185
|
+
aux = @head
|
186
|
+
while j < (@size - i)
|
187
|
+
if aux.value.sal > aux.next.value.sal
|
188
|
+
aux.value, aux.next.value = aux.next.value, aux.value
|
189
|
+
end
|
190
|
+
aux = aux.next
|
191
|
+
j+=1
|
192
|
+
end
|
193
|
+
i+=1
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
#Metodo each utilizado para poder hacer uso del modulo Enumerable
|
199
|
+
def each
|
200
|
+
aux = @head
|
201
|
+
while aux != nil do
|
202
|
+
yield aux.value
|
203
|
+
aux = aux.next
|
204
|
+
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
|