prct08 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Guardfile +82 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/doc/Dieta.html +364 -0
- data/doc/Lista.html +1223 -0
- data/doc/Menu.html +1102 -0
- data/doc/Menu_alimento.html +377 -0
- data/doc/Menu_edad.html +377 -0
- data/doc/Nodo.html +400 -0
- data/doc/Plato.html +489 -0
- data/doc/Prct08.html +119 -0
- data/doc/_index.html +176 -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 +128 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +128 -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 +411 -0
- data/doc/top-level-namespace.html +114 -0
- data/lib/prct08.rb +5 -0
- data/lib/prct08/dieta.rb +23 -0
- data/lib/prct08/lista.rb +161 -0
- data/lib/prct08/menu.rb +92 -0
- data/lib/prct08/menu_alimento.rb +15 -0
- data/lib/prct08/menu_dsl.rb +57 -0
- data/lib/prct08/menu_edad.rb +15 -0
- data/lib/prct08/plato.rb +17 -0
- data/lib/prct08/version.rb +3 -0
- data/prct08.gemspec +40 -0
- metadata +171 -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="Prct08.html" title="Prct08 (module)">Prct08</a></span>
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Dieta.html" title="Dieta (class)">Dieta</a></span>, <span class='object_link'><a href="Lista.html" title="Lista (class)">Lista</a></span>, <span class='object_link'><a href="Menu.html" title="Menu (class)">Menu</a></span>, <span class='object_link'><a href="Menu_alimento.html" title="Menu_alimento (class)">Menu_alimento</a></span>, <span class='object_link'><a href="Menu_edad.html" title="Menu_edad (class)">Menu_edad</a></span>, <span class='object_link'><a href="Nodo.html" title="Nodo (class)">Nodo</a></span>, <span class='object_link'><a href="Plato.html" title="Plato (class)">Plato</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 Thu Nov 24 18:35:14 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>
|
data/lib/prct08.rb
ADDED
data/lib/prct08/dieta.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#require './menu'
|
2
|
+
|
3
|
+
class Dieta
|
4
|
+
|
5
|
+
attr_accessor :menus #geters y serters asi nos ahorramos escribirlo
|
6
|
+
|
7
|
+
def initialize(menus)
|
8
|
+
@menus = menus
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
string =""
|
14
|
+
@menus.each_with_index do |elem, i|
|
15
|
+
string+="#{elem.to_s}\n\n" #llama al metodo to_s de la clase menu
|
16
|
+
end
|
17
|
+
|
18
|
+
return string
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
data/lib/prct08/lista.rb
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
Nodo = Struct.new(:value, :next, :before)
|
2
|
+
|
3
|
+
class Lista
|
4
|
+
attr_accessor :head, :tail, :size
|
5
|
+
include Enumerable
|
6
|
+
def initialize
|
7
|
+
@head = nil #Cabecera de la lista
|
8
|
+
@tail = nil #Cola de la lista
|
9
|
+
@size = 0 #Tamaño de la lista
|
10
|
+
end
|
11
|
+
|
12
|
+
def insert_head(nodo)
|
13
|
+
if empty
|
14
|
+
nodo[:next] = nil
|
15
|
+
nodo[:before] = nil
|
16
|
+
@head = nodo
|
17
|
+
@tail = nodo
|
18
|
+
else
|
19
|
+
nodo[:next] = @head
|
20
|
+
@head[:before] = nodo
|
21
|
+
nodo[:before] = nil
|
22
|
+
@head = nodo
|
23
|
+
end
|
24
|
+
@size = @size + 1
|
25
|
+
end
|
26
|
+
|
27
|
+
def insert_tail(nodo)
|
28
|
+
if empty
|
29
|
+
nodo[:next] = nil
|
30
|
+
nodo[:before] = nil
|
31
|
+
@head = nodo
|
32
|
+
@tail = nodo
|
33
|
+
else
|
34
|
+
@tail[:next] = nodo
|
35
|
+
nodo[:next] = nil
|
36
|
+
nodo[:before] = @tail
|
37
|
+
@tail = nodo
|
38
|
+
end
|
39
|
+
@size = @size + 1
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_pos(index)
|
43
|
+
pos = 0
|
44
|
+
aux = @head
|
45
|
+
while pos != (index - 1) do
|
46
|
+
pos = pos + 1
|
47
|
+
aux = aux.next
|
48
|
+
end
|
49
|
+
return aux
|
50
|
+
end
|
51
|
+
|
52
|
+
def insert_pos(nodo, index)
|
53
|
+
pos = 0
|
54
|
+
aux = @head
|
55
|
+
if pos == 1
|
56
|
+
insert_head(nodo)
|
57
|
+
end
|
58
|
+
if pos == size
|
59
|
+
insert_tail(nodo)
|
60
|
+
else
|
61
|
+
while(pos != (index - 1) && (aux.next != nil)) do
|
62
|
+
if pos == index - 2
|
63
|
+
nodo[:next] = aux.next
|
64
|
+
nodo[:before] = aux
|
65
|
+
aux[:next] = nodo
|
66
|
+
end
|
67
|
+
if pos == index - 1
|
68
|
+
aux = nodo.next
|
69
|
+
aux[:before] = nodo
|
70
|
+
else
|
71
|
+
pos = pos + 1
|
72
|
+
aux = aux.next
|
73
|
+
end
|
74
|
+
@size = @size + 1
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def insert_mul (nodos, index)
|
80
|
+
for i in 0..(nodos.length - 1)
|
81
|
+
insert_pos(nodos[i], index)
|
82
|
+
index = index + 1
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def extract_head
|
87
|
+
if @head == nil
|
88
|
+
@tail = nil
|
89
|
+
else
|
90
|
+
aux = @head
|
91
|
+
@head = @head.next
|
92
|
+
@size = @size - 1
|
93
|
+
end
|
94
|
+
return aux
|
95
|
+
end
|
96
|
+
|
97
|
+
def extract_tail
|
98
|
+
if @head == @tail
|
99
|
+
return @tail
|
100
|
+
@head = nil
|
101
|
+
@tail = nil
|
102
|
+
@size = @size - 1
|
103
|
+
else
|
104
|
+
aux = @tail
|
105
|
+
@tail = aux[:before]
|
106
|
+
@tail[:next] = nil
|
107
|
+
@size = @size - 1
|
108
|
+
return aux
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def extract_pos(index)
|
113
|
+
pos = 0
|
114
|
+
aux = @head
|
115
|
+
if pos == index - 1
|
116
|
+
extract_head()
|
117
|
+
end
|
118
|
+
if index == @size
|
119
|
+
extract_tail()
|
120
|
+
else
|
121
|
+
while (pos != (index - 1)) && (aux.next != nil) do
|
122
|
+
pos = pos + 1
|
123
|
+
aux = aux.next
|
124
|
+
end
|
125
|
+
auxBef = aux.before
|
126
|
+
auxNext = aux.next
|
127
|
+
auxBef[:next] = auxNext
|
128
|
+
auxNext[:before] = auxBef
|
129
|
+
return aux
|
130
|
+
@size = @size - 1
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def to_s
|
135
|
+
aux = @head
|
136
|
+
if empty != true
|
137
|
+
string = ""
|
138
|
+
while aux.next != nil
|
139
|
+
string += "\n\n#{aux.value}"
|
140
|
+
aux = aux.next
|
141
|
+
end
|
142
|
+
string += "\n\n#{aux.value}"
|
143
|
+
return string
|
144
|
+
else
|
145
|
+
return "Lista vacia"
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def empty
|
150
|
+
return size==0
|
151
|
+
end
|
152
|
+
|
153
|
+
def each
|
154
|
+
aux = @head
|
155
|
+
while aux != nil
|
156
|
+
yield aux.value
|
157
|
+
aux = aux.next
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
data/lib/prct08/menu.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
#require './plato'
|
2
|
+
|
3
|
+
class Menu
|
4
|
+
|
5
|
+
attr_accessor :titulo, :ingestaPor, :platos, :valorCT, :porcentajePro, :porcentajeGra, :porcentajeHid #geters y serters asi nos ahorramos escribirlo
|
6
|
+
|
7
|
+
include Comparable
|
8
|
+
|
9
|
+
def initialize(titulo, ingestaPor, platos, valorCT, porcentajePro, porcentajeGra, porcentajeHid)
|
10
|
+
@titulo = titulo
|
11
|
+
@ingestaPor = ingestaPor
|
12
|
+
@platos = platos
|
13
|
+
@valorCT = valorCT
|
14
|
+
@porcentajePro = porcentajePro
|
15
|
+
@porcentajeGra = porcentajeGra
|
16
|
+
@porcentajeHid = porcentajeHid
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def getPlato(pos)
|
21
|
+
|
22
|
+
if(pos-1 >= platos.length || pos-1 < 0)
|
23
|
+
return (puts "Error posicion no valida")
|
24
|
+
end
|
25
|
+
|
26
|
+
if(pos-1 < platos.length)
|
27
|
+
return platos[pos-1]
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def getConjPlatos
|
33
|
+
return platos
|
34
|
+
end
|
35
|
+
|
36
|
+
def <=> (otro)
|
37
|
+
return nil unless otro.is_a?Menu #Si el otro objeto no es del tipo menu devuelve nil
|
38
|
+
if (@valorCT[0] == otro.valorCT[0])
|
39
|
+
if(@platos.length == otro.platos.length)
|
40
|
+
return 0
|
41
|
+
else
|
42
|
+
if(@platos.length < otro.platos.length)
|
43
|
+
return -1
|
44
|
+
end
|
45
|
+
return 1
|
46
|
+
end
|
47
|
+
else
|
48
|
+
if(@valorCT[0] < otro.valorCT[0])
|
49
|
+
return -1
|
50
|
+
end
|
51
|
+
return 1
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def ==(otro)
|
56
|
+
if otro.is_a?Menu
|
57
|
+
@titulo == otro.titulo &&
|
58
|
+
@ingestaPor == otro.ingestaPor &&
|
59
|
+
@platos == otro.platos &&
|
60
|
+
@valorCT == otro.valorCT &&
|
61
|
+
@porcentajePro == otro.porcentajePro &&
|
62
|
+
@porcentajeGra == otro.porcentajeGra &&
|
63
|
+
@porcentajeHid == otro.porcentajeHid
|
64
|
+
else
|
65
|
+
false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def to_s
|
70
|
+
string = "#{@titulo} ("
|
71
|
+
|
72
|
+
@ingestaPor.each_with_index do |elem,i|
|
73
|
+
if(i==1)
|
74
|
+
string+=" - "
|
75
|
+
end
|
76
|
+
string+= "#{elem}"
|
77
|
+
end
|
78
|
+
string+="%)\n"
|
79
|
+
|
80
|
+
@platos.each_with_index do |elem,i|
|
81
|
+
string+="- #{elem.to_s}\n"
|
82
|
+
end
|
83
|
+
|
84
|
+
string+="V.C.T. | % #{valorCT[0]} #{valorCT[1]} | #{porcentajePro}% - #{porcentajeGra}% - #{porcentajeHid}%"
|
85
|
+
|
86
|
+
return string
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#require "menu.rb"
|
2
|
+
|
3
|
+
class Menu_alimento < Menu
|
4
|
+
attr_accessor :gAlimentos
|
5
|
+
|
6
|
+
def initialize(titulo, ingestaPor, platos, valorCT, porcentajePro, porcentajeGra, porcentajeHid, grupoAlimentos)
|
7
|
+
super(titulo, ingestaPor, platos, valorCT, porcentajePro, porcentajeGra, porcentajeHid)
|
8
|
+
@gAlimentos = grupoAlimentos
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
string = "Menu con alimentos del tipo: #{gAlimentos}\n" + super.to_s
|
13
|
+
return string
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class Menu_dsl
|
2
|
+
attr_accessor :etiqueta, :titulo, :ingestaIn, :platosIn, :porcentajeIn
|
3
|
+
|
4
|
+
def initialize(etiqueta, &block)
|
5
|
+
self.etiqueta = etiqueta
|
6
|
+
self.titulo = ""
|
7
|
+
self.ingestaIn = []
|
8
|
+
self.platosIn = []
|
9
|
+
self.porcentajeIn = []
|
10
|
+
|
11
|
+
if block_given?
|
12
|
+
if block.arity == 1
|
13
|
+
yield self
|
14
|
+
else
|
15
|
+
instance_eval(&block)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def titulos(options = {})
|
21
|
+
titulo << "#{options[:titulo]}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def ingesta(options = {})
|
25
|
+
ingestaIn << "#{options[:min]}" if options[:min]
|
26
|
+
ingestaIn << "#{options[:max]}" if options[:max]
|
27
|
+
end
|
28
|
+
|
29
|
+
def platos(options = {})
|
30
|
+
plato = []
|
31
|
+
plato << "#{options[:descripcion]}" if options[:descripcion]
|
32
|
+
plato << "#{options[:porcion]}" if options[:porcion]
|
33
|
+
plato << "#{options[:gramos]}" if options[:gramos]
|
34
|
+
platosIn << plato
|
35
|
+
end
|
36
|
+
|
37
|
+
def porcentajes(options = {})
|
38
|
+
porcentaje = []
|
39
|
+
porcentaje << "#{options[:vct]}" if options[:vct]
|
40
|
+
porcentaje << "#{options[:proteinas]}" if options[:proteinas]
|
41
|
+
porcentaje << "#{options[:grasas]}" if options[:grasas]
|
42
|
+
porcentaje << "#{options[:hidratos]}" if options[:hidratos]
|
43
|
+
porcentajeIn << porcentaje
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_s
|
47
|
+
out = "#{titulo}"
|
48
|
+
out << "\nMinima: #{ingestaIn[0]} % - Maximo: #{ingestaIn[1]} %"
|
49
|
+
platosIn.each_with_index do |plato, index|
|
50
|
+
out << "\n\tDescripcion: #{plato[0]} \n\tPorcion: #{plato[1]} \n\tGramos: #{plato[2]}\n"
|
51
|
+
end
|
52
|
+
porcentajeIn.each_with_index do |porcentaje, index|
|
53
|
+
out << "\n\tV.C.T: #{porcentaje[0]} \n\tProteinas: #{porcentaje[1]} \n\tGrasas: #{porcentaje[2]} \n\tHidratos:#{porcentaje[3]} \n"
|
54
|
+
end
|
55
|
+
out
|
56
|
+
end
|
57
|
+
end
|