prct11_abian 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/Guardfile +82 -0
- data/LICENSE.txt +21 -0
- data/README.md +56 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/doc/Diet.html +1093 -0
- data/doc/DslDieta.html +1299 -0
- data/doc/LinkedList.html +1173 -0
- data/doc/MenuAge.html +461 -0
- data/doc/MenuFood.html +459 -0
- data/doc/Prct06.html +117 -0
- data/doc/_index.html +158 -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 +481 -0
- data/doc/file.README.html +104 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +104 -0
- data/doc/js/app.js +243 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +371 -0
- data/doc/top-level-namespace.html +114 -0
- data/lib/prct06/dslDieta.rb +64 -0
- data/lib/prct06/linkedList.rb +209 -0
- data/lib/prct06/menuAge.rb +42 -0
- data/lib/prct06/menuFood.rb +44 -0
- data/lib/prct06/prct06.rb +98 -0
- data/lib/prct06/version.rb +3 -0
- data/prct06.gemspec +39 -0
- metadata +169 -0
@@ -0,0 +1,114 @@
|
|
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.5
|
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"></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
|
+
<iframe id="search_frame" src="class_list.html"></iframe>
|
63
|
+
|
64
|
+
<div id="content"><h1>Top Level Namespace
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
</h1>
|
69
|
+
<div class="box_info">
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
<h2>Defined Under Namespace</h2>
|
84
|
+
<p class="children">
|
85
|
+
|
86
|
+
|
87
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Prct06.html" title="Prct06 (module)">Prct06</a></span>
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Diet.html" title="Diet (class)">Diet</a></span>, <span class='object_link'><a href="DslDieta.html" title="DslDieta (class)">DslDieta</a></span>, <span class='object_link'><a href="LinkedList.html" title="LinkedList (class)">LinkedList</a></span>, <span class='object_link'><a href="MenuAge.html" title="MenuAge (class)">MenuAge</a></span>, <span class='object_link'><a href="MenuFood.html" title="MenuFood (class)">MenuFood</a></span>
|
92
|
+
|
93
|
+
|
94
|
+
</p>
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
</div>
|
105
|
+
|
106
|
+
<div id="footer">
|
107
|
+
Generated on Tue Dec 13 16:00:37 2016 by
|
108
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
109
|
+
0.9.5 (ruby-2.3.0).
|
110
|
+
</div>
|
111
|
+
|
112
|
+
</div>
|
113
|
+
</body>
|
114
|
+
</html>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#<!--
|
2
|
+
# @markup ruby
|
3
|
+
# @title Almacena tus dietas
|
4
|
+
# @author Abián Torres Torres (alu0100887686@ull.edu.es)
|
5
|
+
#-->
|
6
|
+
require "prct06/version"
|
7
|
+
class DslDieta
|
8
|
+
include Comparable
|
9
|
+
# @overload Método de acceso y escritura para los atributos de instancia.
|
10
|
+
attr_accessor :titulo,:max,:min,:vct,:proteinas,:grasas,:hidratos,:platos
|
11
|
+
# @note Método por el cual se inicializa la dieta mediante el título y un bloque
|
12
|
+
# @param [String] Título, [Block] Block
|
13
|
+
def initialize(titulo,&block)
|
14
|
+
self.titulo=titulo
|
15
|
+
self.platos =[]
|
16
|
+
if block_given?
|
17
|
+
if block.arity == 1
|
18
|
+
yield self
|
19
|
+
else
|
20
|
+
instance_eval(&block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
# @note Función que permite mostrar una salida formateada de la lista
|
25
|
+
# @return [String] String con el contenido de la lista
|
26
|
+
def to_s
|
27
|
+
output = "#{titulo} (#{min}-#{max}%):\n"
|
28
|
+
i=0
|
29
|
+
begin
|
30
|
+
output+="#{platos[i]}\n"
|
31
|
+
i+=1
|
32
|
+
end while (i<platos.length)
|
33
|
+
output += "V.C.T. | % #{vct} kcal | #{proteinas}% - #{grasas}% - #{hidratos}%\n"
|
34
|
+
"#{output}"
|
35
|
+
end
|
36
|
+
# @note Función que permite comparar dos dietas en función de sus valor calorífico.
|
37
|
+
# @param [Diet] Menú a comparar
|
38
|
+
# @return [Int] 1 if self>other, 0 if self == other, -1 if self<other
|
39
|
+
def <=>(other)
|
40
|
+
self.vct<=>other.vct
|
41
|
+
end
|
42
|
+
# @note Función que permite asignar valor a los atributos max y min.
|
43
|
+
# @param [Hash] Parámetro min y max
|
44
|
+
def ingesta(args = {})
|
45
|
+
self.max="#{args[:max]}" if args[:max]
|
46
|
+
self.min="#{args[:min]}" if args[:min]
|
47
|
+
end
|
48
|
+
# @note Función que permite añadir un nuevo plato a la dieta.
|
49
|
+
# @param [Hash] Parámetros descripcion, porcion y gramos
|
50
|
+
def plato(args = {})
|
51
|
+
input = " -#{args[:descripcion]}" if args[:descripcion]
|
52
|
+
input += ", #{args[:porcion]}" if args[:porcion]
|
53
|
+
input += ", #{args[:gramos]} gramos" if args[:gramos]
|
54
|
+
self.platos << "#{input}"
|
55
|
+
end
|
56
|
+
# @note Función que permite asignar valor a los parámetros: vct, proteinas, grasas y hidratos.
|
57
|
+
# @param [Hash] Parámetros descripcion, porcion y gramos
|
58
|
+
def porcentajes(args = {})
|
59
|
+
self.vct="#{args[:vct]}" if args[:vct]
|
60
|
+
self.proteinas="#{args[:proteinas]}" if args[:proteinas]
|
61
|
+
self.grasas="#{args[:grasas]}" if args[:grasas]
|
62
|
+
self.hidratos="#{args[:hidratos]}" if args[:hidratos]
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,209 @@
|
|
1
|
+
#<!--
|
2
|
+
# @markup ruby
|
3
|
+
# @title Almacena tu información en una lista doblemente enlazada
|
4
|
+
# @author Abián Torres Torres (alu0100887686@ull.edu.es)
|
5
|
+
#-->
|
6
|
+
|
7
|
+
#nombre : Abián Torres Torres
|
8
|
+
#Email : alu0100887686@ull.edu.es
|
9
|
+
|
10
|
+
#Implementación de una clase para el manejo
|
11
|
+
#de listas doblemente enlazada
|
12
|
+
|
13
|
+
require "prct06/version"
|
14
|
+
|
15
|
+
class LinkedList
|
16
|
+
|
17
|
+
include Enumerable
|
18
|
+
|
19
|
+
# @overload Método de acceso y escritura para la cabeza de la lista
|
20
|
+
|
21
|
+
attr_accessor :head
|
22
|
+
|
23
|
+
# @overload Estructura Global que representará un dato de tipo nodo
|
24
|
+
|
25
|
+
Struct.new("Node", :value, :prev, :next)
|
26
|
+
|
27
|
+
# @note La clase se inicializa con la cabeza a nil
|
28
|
+
|
29
|
+
def initialize()
|
30
|
+
|
31
|
+
@head = nil
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
# @note Método por el cual se introduce un elemento por el principio
|
36
|
+
# @param [Any Type] Valor a introducir
|
37
|
+
|
38
|
+
def putFirst(value)
|
39
|
+
|
40
|
+
#Inicializamos un nodo auxiliar con el valor a introducir
|
41
|
+
#Y apuntando como siguiente a head:
|
42
|
+
|
43
|
+
node = Struct::Node.new(value,nil, @head)
|
44
|
+
|
45
|
+
#Hacemos que el head tome el comportamiento del nodo creado
|
46
|
+
|
47
|
+
@head = node
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
# @note Método que permite eliminar un elemento por el principio
|
52
|
+
# @return [Any Type] Elemento eliminado
|
53
|
+
|
54
|
+
def deleteFirst()
|
55
|
+
|
56
|
+
#Si la lista no está vacía movemos una posición head
|
57
|
+
#y el prev apuntará a nil:
|
58
|
+
|
59
|
+
tmp = @head
|
60
|
+
|
61
|
+
if @head != nil
|
62
|
+
|
63
|
+
@head = @head.next
|
64
|
+
|
65
|
+
@head.prev = nil
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
tmp
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
# @note Función que permite añadir un nuevo nodo a la lista por el final
|
74
|
+
# @param [Any Type] Valor a introducir
|
75
|
+
|
76
|
+
def putLast(value)
|
77
|
+
|
78
|
+
#Si aún no se ha introducido ningún nodo en la lista,
|
79
|
+
#tanto el head como el tail apuntarán al mismo nodo
|
80
|
+
#de lo contratio, añadiremos un nodo a continuación de tail:
|
81
|
+
|
82
|
+
if @head != nil
|
83
|
+
|
84
|
+
#Desplazamos el head hasta la última posición:
|
85
|
+
|
86
|
+
while @head.next != nil
|
87
|
+
|
88
|
+
tmp = @head
|
89
|
+
|
90
|
+
@head = @head.next
|
91
|
+
|
92
|
+
@head.prev = tmp
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
#Inicializamos un nodo auxiliar con el valor a introducir:
|
97
|
+
|
98
|
+
node = Struct::Node.new(value, @head, nil)
|
99
|
+
|
100
|
+
#Colocamos el node a continuación del último
|
101
|
+
|
102
|
+
@head.next = node
|
103
|
+
|
104
|
+
#Desplazamos nuevamente el head a la posición inicial:
|
105
|
+
|
106
|
+
while @head.prev != nil
|
107
|
+
|
108
|
+
@head = @head.prev
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
else
|
113
|
+
|
114
|
+
#Creamos el nodo inicial:
|
115
|
+
|
116
|
+
node = Struct::Node.new(value, nil, nil)
|
117
|
+
|
118
|
+
@head = node
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
# @note Método que permite eliminar un elemento por el final
|
125
|
+
# @return [Any Type] Elemento eliminado
|
126
|
+
|
127
|
+
def deleteLast()
|
128
|
+
|
129
|
+
#Si la lista no está vacía:
|
130
|
+
|
131
|
+
if @head != nil
|
132
|
+
|
133
|
+
#Desplazamos el head hasta la penúltima posición:
|
134
|
+
|
135
|
+
while @head.next.next != nil
|
136
|
+
|
137
|
+
tmp = @head
|
138
|
+
|
139
|
+
@head = @head.next
|
140
|
+
|
141
|
+
@head.prev = tmp
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
#Ponemos el siguiente en la penúltima posición a nil:
|
146
|
+
|
147
|
+
foo = @head.next
|
148
|
+
|
149
|
+
@head.next = nil
|
150
|
+
|
151
|
+
#Desplazamos nuevamente el head a la posición inicial:
|
152
|
+
|
153
|
+
while @head.prev != nil
|
154
|
+
|
155
|
+
@head = @head.prev
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
foo
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
# @note Función que permite mostrar una salida formateada de la lista
|
166
|
+
# @return [String] String con el contenido de la lista
|
167
|
+
|
168
|
+
def to_s()
|
169
|
+
|
170
|
+
#Para no modificar la estructura de la lista,
|
171
|
+
#utilizaremos una variable temporal, la cual será
|
172
|
+
#desplazada al siguiente nodo en cada iteración:
|
173
|
+
|
174
|
+
tmp = @head
|
175
|
+
|
176
|
+
#String que almacenará el contenido a mostrar:
|
177
|
+
|
178
|
+
aux = ""
|
179
|
+
|
180
|
+
while tmp != nil
|
181
|
+
|
182
|
+
aux += "#{tmp.value}\n"
|
183
|
+
|
184
|
+
tmp = tmp.next
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
aux
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
# @note Función retorna los bloques que se indique por parámetro en la invocación del método
|
193
|
+
# @return [Any Type] Bloques seleccionados
|
194
|
+
|
195
|
+
def each
|
196
|
+
|
197
|
+
tmp = @head
|
198
|
+
|
199
|
+
while tmp != nil do
|
200
|
+
|
201
|
+
yield tmp.value
|
202
|
+
|
203
|
+
tmp = tmp.next
|
204
|
+
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#<!--
|
2
|
+
# @markup ruby
|
3
|
+
# @title Almacena tus dietas agrupadas por edades
|
4
|
+
# @author Abián Torres Torres (alu0100887686@ull.edu.es)
|
5
|
+
#-->
|
6
|
+
|
7
|
+
#Implementación de una clase hija de Diet para
|
8
|
+
#agrupar los menú por edades:
|
9
|
+
|
10
|
+
require "prct06/version"
|
11
|
+
|
12
|
+
class MenuAge < Diet
|
13
|
+
|
14
|
+
# @overload Método de acceso y escritura para el atributo que almacenará el rango de edad
|
15
|
+
|
16
|
+
attr_accessor :age
|
17
|
+
|
18
|
+
# @note Método para inicializar una dieta agrupada por edades
|
19
|
+
# @param [String] Rango de edad, [String] Título, [String] Ingesta diaria, [String] Valor calorífico,
|
20
|
+
# @param [String] Porcentaje de proteínas, [String] Porcentaje de proteínas, [String] Porcentaje de grasas
|
21
|
+
# @param [String] Porcentaje de hidratos de carbono
|
22
|
+
|
23
|
+
def initialize(age, ttl, dip, vct, pprtn, pfts, pchdt)
|
24
|
+
|
25
|
+
@age = age
|
26
|
+
|
27
|
+
super(ttl, dip, vct, pprtn, pfts, pchdt)
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
# @note Función que permite mostrar una salida formateada de la lista
|
32
|
+
# @return [String] String con el contenido de la lista
|
33
|
+
|
34
|
+
def to_s()
|
35
|
+
|
36
|
+
tmp = super.to_s + "Edad: #{@age}\n"
|
37
|
+
|
38
|
+
tmp
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#<!--
|
2
|
+
# @markup ruby
|
3
|
+
# @title Almacena tus dietas agrupadas por alimentos
|
4
|
+
# @author Abián Torres Torres (alu0100887686@ull.edu.es)
|
5
|
+
#-->
|
6
|
+
|
7
|
+
#nombre : Abián Torres Torres
|
8
|
+
#Email : alu0100887686@ull.edu.es
|
9
|
+
|
10
|
+
#Implementación de una clase hija de Diet para
|
11
|
+
#agrupar los menú por alimentos:
|
12
|
+
|
13
|
+
require "prct06/version"
|
14
|
+
|
15
|
+
class MenuFood < Diet
|
16
|
+
|
17
|
+
# @overload Método de acceso y escritura para el atributo que almacenará el grupo de alimentos
|
18
|
+
|
19
|
+
attr_accessor :food
|
20
|
+
|
21
|
+
# @note Método para inicializar una dieta agrupada por alimentos
|
22
|
+
# @param [String] Grupo de alimentos, [String] Título, [String] Ingesta diaria, [String] Valor calorífico,
|
23
|
+
# @param [String] Porcentaje de proteínas, [String] Porcentaje de proteínas, [String] Porcentaje de grasas
|
24
|
+
# @param [String] Porcentaje de hidratos de carbono
|
25
|
+
|
26
|
+
def initialize(food, ttl, dip, vct, pprtn, pfts, pchdt)
|
27
|
+
|
28
|
+
@food = food
|
29
|
+
|
30
|
+
super(ttl, dip, vct, pprtn, pfts, pchdt)
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
# @note Función que permite mostrar una salida formateada de la lista
|
35
|
+
# @return [String] String con el contenido de la lista
|
36
|
+
|
37
|
+
def to_s()
|
38
|
+
|
39
|
+
tmp = super.to_s + "Alimentos: #{@food}\n"
|
40
|
+
tmp
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|