alu0100905885 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/.coveralls.yml +1 -0
- data/.travis.yml +12 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/doc/Alimentos.html +513 -0
- data/doc/CODE_OF_CONDUCT_md.html +192 -0
- data/doc/Gemfile.html +98 -0
- data/doc/LICENSE_txt.html +114 -0
- data/doc/Listas.html +512 -0
- data/doc/Object.html +126 -0
- data/doc/Plato_.html +409 -0
- data/doc/Platos.html +389 -0
- data/doc/Prct6.html +108 -0
- data/doc/Prct6/Error.html +101 -0
- data/doc/README_md.html +169 -0
- data/doc/Rakefile.html +98 -0
- data/doc/bin/setup.html +98 -0
- data/doc/created.rid +16 -0
- data/doc/css/fonts.css +167 -0
- data/doc/css/rdoc.css +590 -0
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +114 -0
- data/doc/js/darkfish.js +161 -0
- data/doc/js/jquery.js +5 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search.js +109 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js +229 -0
- data/doc/js/searcher.js.gz +0 -0
- data/doc/prct6_gemspec.html +129 -0
- data/doc/table_of_contents.html +238 -0
- data/lib/prct6.rb +11 -0
- data/lib/prct6/listas.rb +68 -0
- data/lib/prct6/menu_dsl.rb +33 -0
- data/lib/prct6/plato_dsl.rb +29 -0
- data/lib/prct6/platos.rb +154 -0
- data/lib/prct6/prct6.rb +62 -0
- data/lib/prct6/version.rb +3 -0
- data/pkg/alu0100905885-0.1.0.gem +0 -0
- data/pkg/prct6-0.1.0.gem +0 -0
- data/prct6.gemspec +34 -0
- metadata +208 -0
@@ -0,0 +1,238 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>Table of Contents - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "./";
|
11
|
+
var index_rel_prefix = "./";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="./js/jquery.js"></script>
|
15
|
+
<script src="./js/darkfish.js"></script>
|
16
|
+
|
17
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
18
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
<body id="top" class="table-of-contents">
|
23
|
+
<main role="main">
|
24
|
+
<h1 class="class">Table of Contents - RDoc Documentation</h1>
|
25
|
+
|
26
|
+
<h2 id="pages">Pages</h2>
|
27
|
+
<ul>
|
28
|
+
<li class="file">
|
29
|
+
<a href="CODE_OF_CONDUCT_md.html">CODE_OF_CONDUCT</a>
|
30
|
+
|
31
|
+
<ul>
|
32
|
+
<li><a href="CODE_OF_CONDUCT_md.html#label-Contributor+Covenant+Code+of+Conduct">Contributor Covenant Code of Conduct</a>
|
33
|
+
<li><a href="CODE_OF_CONDUCT_md.html#label-Our+Pledge">Our Pledge</a>
|
34
|
+
<li><a href="CODE_OF_CONDUCT_md.html#label-Our+Standards">Our Standards</a>
|
35
|
+
<li><a href="CODE_OF_CONDUCT_md.html#label-Our+Responsibilities">Our Responsibilities</a>
|
36
|
+
<li><a href="CODE_OF_CONDUCT_md.html#label-Scope">Scope</a>
|
37
|
+
<li><a href="CODE_OF_CONDUCT_md.html#label-Enforcement">Enforcement</a>
|
38
|
+
<li><a href="CODE_OF_CONDUCT_md.html#label-Attribution">Attribution</a>
|
39
|
+
</ul>
|
40
|
+
</li>
|
41
|
+
<li class="file">
|
42
|
+
<a href="Gemfile.html">Gemfile</a>
|
43
|
+
</li>
|
44
|
+
<li class="file">
|
45
|
+
<a href="LICENSE_txt.html">LICENSE</a>
|
46
|
+
</li>
|
47
|
+
<li class="file">
|
48
|
+
<a href="README_md.html">README</a>
|
49
|
+
|
50
|
+
<ul>
|
51
|
+
<li><a href="README_md.html#label-Prct6">Prct6</a>
|
52
|
+
<li><a href="README_md.html#label-Installation">Installation</a>
|
53
|
+
<li><a href="README_md.html#label-Usage">Usage</a>
|
54
|
+
<li><a href="README_md.html#label-Development">Development</a>
|
55
|
+
<li><a href="README_md.html#label-Contributing">Contributing</a>
|
56
|
+
<li><a href="README_md.html#label-License">License</a>
|
57
|
+
<li><a href="README_md.html#label-Code+of+Conduct">Code of Conduct</a>
|
58
|
+
</ul>
|
59
|
+
</li>
|
60
|
+
<li class="file">
|
61
|
+
<a href="Rakefile.html">Rakefile</a>
|
62
|
+
</li>
|
63
|
+
<li class="file">
|
64
|
+
<a href="bin/setup.html">setup</a>
|
65
|
+
</li>
|
66
|
+
<li class="file">
|
67
|
+
<a href="prct6_gemspec.html">prct6.gemspec</a>
|
68
|
+
</li>
|
69
|
+
|
70
|
+
</ul>
|
71
|
+
|
72
|
+
<h2 id="classes">Classes and Modules</h2>
|
73
|
+
<ul>
|
74
|
+
<li class="class">
|
75
|
+
<a href="Alimentos.html">Alimentos</a>
|
76
|
+
</li>
|
77
|
+
<li class="class">
|
78
|
+
<a href="Listas.html">Listas</a>
|
79
|
+
</li>
|
80
|
+
<li class="class">
|
81
|
+
<a href="Object.html">Object</a>
|
82
|
+
</li>
|
83
|
+
<li class="class">
|
84
|
+
<a href="Plato_.html">Plato_</a>
|
85
|
+
</li>
|
86
|
+
<li class="class">
|
87
|
+
<a href="Platos.html">Platos</a>
|
88
|
+
</li>
|
89
|
+
<li class="module">
|
90
|
+
<a href="Prct6.html">Prct6</a>
|
91
|
+
</li>
|
92
|
+
<li class="class">
|
93
|
+
<a href="Prct6/Error.html">Prct6::Error</a>
|
94
|
+
</li>
|
95
|
+
</ul>
|
96
|
+
|
97
|
+
<h2 id="methods">Methods</h2>
|
98
|
+
<ul>
|
99
|
+
|
100
|
+
<li class="method">
|
101
|
+
<a href="Listas.html#method-c-new">::new</a>
|
102
|
+
—
|
103
|
+
<span class="container">Listas</span>
|
104
|
+
|
105
|
+
<li class="method">
|
106
|
+
<a href="Platos.html#method-c-new">::new</a>
|
107
|
+
—
|
108
|
+
<span class="container">Platos</span>
|
109
|
+
|
110
|
+
<li class="method">
|
111
|
+
<a href="Plato_.html#method-c-new">::new</a>
|
112
|
+
—
|
113
|
+
<span class="container">Plato_</span>
|
114
|
+
|
115
|
+
<li class="method">
|
116
|
+
<a href="Alimentos.html#method-c-new">::new</a>
|
117
|
+
—
|
118
|
+
<span class="container">Alimentos</span>
|
119
|
+
|
120
|
+
<li class="method">
|
121
|
+
<a href="Plato_.html#method-i-3C-3D-3E">#<=></a>
|
122
|
+
—
|
123
|
+
<span class="container">Plato_</span>
|
124
|
+
|
125
|
+
<li class="method">
|
126
|
+
<a href="Alimentos.html#method-i-3C-3D-3E">#<=></a>
|
127
|
+
—
|
128
|
+
<span class="container">Alimentos</span>
|
129
|
+
|
130
|
+
<li class="method">
|
131
|
+
<a href="Alimentos.html#method-i-cal">#cal</a>
|
132
|
+
—
|
133
|
+
<span class="container">Alimentos</span>
|
134
|
+
|
135
|
+
<li class="method">
|
136
|
+
<a href="Platos.html#method-i-cal_plato">#cal_plato</a>
|
137
|
+
—
|
138
|
+
<span class="container">Platos</span>
|
139
|
+
|
140
|
+
<li class="method">
|
141
|
+
<a href="Alimentos.html#method-i-d_emision">#d_emision</a>
|
142
|
+
—
|
143
|
+
<span class="container">Alimentos</span>
|
144
|
+
|
145
|
+
<li class="method">
|
146
|
+
<a href="Alimentos.html#method-i-d_nombre">#d_nombre</a>
|
147
|
+
—
|
148
|
+
<span class="container">Alimentos</span>
|
149
|
+
|
150
|
+
<li class="method">
|
151
|
+
<a href="Alimentos.html#method-i-d_proteinas">#d_proteinas</a>
|
152
|
+
—
|
153
|
+
<span class="container">Alimentos</span>
|
154
|
+
|
155
|
+
<li class="method">
|
156
|
+
<a href="Alimentos.html#method-i-d_terreno">#d_terreno</a>
|
157
|
+
—
|
158
|
+
<span class="container">Alimentos</span>
|
159
|
+
|
160
|
+
<li class="method">
|
161
|
+
<a href="Listas.html#method-i-each">#each</a>
|
162
|
+
—
|
163
|
+
<span class="container">Listas</span>
|
164
|
+
|
165
|
+
<li class="method">
|
166
|
+
<a href="Plato_.html#method-i-emisiones_plato">#emisiones_plato</a>
|
167
|
+
—
|
168
|
+
<span class="container">Plato_</span>
|
169
|
+
|
170
|
+
<li class="method">
|
171
|
+
<a href="Listas.html#method-i-extraer_final">#extraer_final</a>
|
172
|
+
—
|
173
|
+
<span class="container">Listas</span>
|
174
|
+
|
175
|
+
<li class="method">
|
176
|
+
<a href="Listas.html#method-i-extraer_inicio">#extraer_inicio</a>
|
177
|
+
—
|
178
|
+
<span class="container">Listas</span>
|
179
|
+
|
180
|
+
<li class="method">
|
181
|
+
<a href="Alimentos.html#method-i-form">#form</a>
|
182
|
+
—
|
183
|
+
<span class="container">Alimentos</span>
|
184
|
+
|
185
|
+
<li class="method">
|
186
|
+
<a href="Plato_.html#method-i-huella">#huella</a>
|
187
|
+
—
|
188
|
+
<span class="container">Plato_</span>
|
189
|
+
|
190
|
+
<li class="method">
|
191
|
+
<a href="Listas.html#method-i-insertar_cabeza">#insertar_cabeza</a>
|
192
|
+
—
|
193
|
+
<span class="container">Listas</span>
|
194
|
+
|
195
|
+
<li class="method">
|
196
|
+
<a href="Listas.html#method-i-insertar_cola">#insertar_cola</a>
|
197
|
+
—
|
198
|
+
<span class="container">Listas</span>
|
199
|
+
|
200
|
+
<li class="method">
|
201
|
+
<a href="Listas.html#method-i-insertar_varios">#insertar_varios</a>
|
202
|
+
—
|
203
|
+
<span class="container">Listas</span>
|
204
|
+
|
205
|
+
<li class="method">
|
206
|
+
<a href="Platos.html#method-i-porcentaje">#porcentaje</a>
|
207
|
+
—
|
208
|
+
<span class="container">Platos</span>
|
209
|
+
|
210
|
+
<li class="method">
|
211
|
+
<a href="Plato_.html#method-i-suma">#suma</a>
|
212
|
+
—
|
213
|
+
<span class="container">Plato_</span>
|
214
|
+
|
215
|
+
<li class="method">
|
216
|
+
<a href="Listas.html#method-i-to_s">#to_s</a>
|
217
|
+
—
|
218
|
+
<span class="container">Listas</span>
|
219
|
+
|
220
|
+
<li class="method">
|
221
|
+
<a href="Platos.html#method-i-to_s">#to_s</a>
|
222
|
+
—
|
223
|
+
<span class="container">Platos</span>
|
224
|
+
|
225
|
+
<li class="method">
|
226
|
+
<a href="Plato_.html#method-i-to_s">#to_s</a>
|
227
|
+
—
|
228
|
+
<span class="container">Plato_</span>
|
229
|
+
</ul>
|
230
|
+
</main>
|
231
|
+
|
232
|
+
|
233
|
+
<footer id="validator-badges" role="contentinfo">
|
234
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
235
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.0.1.
|
236
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
237
|
+
</footer>
|
238
|
+
|
data/lib/prct6.rb
ADDED
data/lib/prct6/listas.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Creación de la clase List con la estructura Node
|
2
|
+
#
|
3
|
+
|
4
|
+
Node = Struct.new(:value, :next, :prev) #Debe existir un nodo con su dato, su siguiente y su previo
|
5
|
+
|
6
|
+
class Listas
|
7
|
+
attr_accessor :head, :nodo_actual,:tail #Debe existir una Lista con su cabeza y su cola
|
8
|
+
|
9
|
+
include Enumerable
|
10
|
+
|
11
|
+
# Metodo initialize
|
12
|
+
# @param parametros head y tail de la lista
|
13
|
+
|
14
|
+
def initialize(head,tail)
|
15
|
+
@head = nil
|
16
|
+
@tail = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
# Se puede insertar un elemento por la cabeza
|
20
|
+
# @param value para insertar elementos
|
21
|
+
|
22
|
+
def insert(value)
|
23
|
+
node = Node.new(value,nil)
|
24
|
+
if (@head == nil)
|
25
|
+
@head = node
|
26
|
+
else
|
27
|
+
@tail.next = node
|
28
|
+
node.prev = @tail
|
29
|
+
end
|
30
|
+
|
31
|
+
@tail=node
|
32
|
+
end
|
33
|
+
|
34
|
+
# Metodo extract_head
|
35
|
+
# @deprecated Sirve para la extracción de la cabeza de la lista
|
36
|
+
|
37
|
+
def extract_head
|
38
|
+
aux=""
|
39
|
+
if (@head!=nil)
|
40
|
+
aux = @head.value
|
41
|
+
@head = @head.next
|
42
|
+
return aux
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Metodo extract_tail
|
47
|
+
# @deprecated Sirve para la extracción por la cola de la lista
|
48
|
+
|
49
|
+
def extract_tail
|
50
|
+
aux=""
|
51
|
+
if(@tail!=nil)
|
52
|
+
aux = @tail.value
|
53
|
+
@tail = @tail.prev
|
54
|
+
return aux
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Metodo each
|
59
|
+
# @deprecated Sirve para recorrer la lista dando el valor del nodo
|
60
|
+
|
61
|
+
def each
|
62
|
+
node = head
|
63
|
+
while (node!=nil)
|
64
|
+
yield node.value
|
65
|
+
node = node.next
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#Clase para representar un Menu con DSL
|
2
|
+
class Menu
|
3
|
+
attr_accessor :nombre,:platos,:precio
|
4
|
+
def initialize(nombre,&block)
|
5
|
+
@nombre = nombre
|
6
|
+
@platos = []
|
7
|
+
@precios=[]
|
8
|
+
@preciototal =0.0
|
9
|
+
|
10
|
+
if block_given?
|
11
|
+
instance_eval(&block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def componente(options={})
|
16
|
+
@platos << options[:plato]
|
17
|
+
@precios << options[:precio]
|
18
|
+
end
|
19
|
+
|
20
|
+
def precio(total)
|
21
|
+
@preciototal = total
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
output = "#{@nombre}"
|
26
|
+
output << " = #{@preciototal}€\n"
|
27
|
+
output << "Contiene: \n"
|
28
|
+
@platos.zip(@precios).each do |x,y|
|
29
|
+
output << "#{x} = #{y}€\n"
|
30
|
+
end
|
31
|
+
output
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#Clase Para representar un Plato con una Lista de Alimento y una Lista de los gramos
|
2
|
+
class Plato_dsl
|
3
|
+
#Incluimos el modulo Comparable para poder comparar Plato
|
4
|
+
include Comparable
|
5
|
+
|
6
|
+
def initialize(nombre_plato, &block)
|
7
|
+
|
8
|
+
@nombre_plato=nombre_plato
|
9
|
+
@alimentos = Listas.new(0,0)
|
10
|
+
@gramos = Listas.new(0,0)
|
11
|
+
|
12
|
+
if block_given?
|
13
|
+
instance_eval(&block)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
#Funcion attr_reader para acceder a los atributos
|
18
|
+
attr_accessor :nombre,:alimentos,:gramos
|
19
|
+
|
20
|
+
def nombre(otro_nombre)
|
21
|
+
@nombre_plato = otro_nombre
|
22
|
+
end
|
23
|
+
|
24
|
+
def alimentos(options ={})
|
25
|
+
aux = Alimentos.new(options[:descripcion],options[:prote],options[:carbohidratos],options[:lipidos],options[:gases],options[:terreno])
|
26
|
+
@alimentos.insert(aux)
|
27
|
+
@gramos.insert(options[:gramos])
|
28
|
+
end
|
29
|
+
end
|
data/lib/prct6/platos.rb
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
# Clase platos que utiliza alimentos
|
2
|
+
|
3
|
+
class Platos
|
4
|
+
|
5
|
+
|
6
|
+
include Comparable
|
7
|
+
|
8
|
+
attr_accessor :nombre, :alimentos, :peso, :peso_total, :cal_array, :emisiones_array
|
9
|
+
|
10
|
+
# Método initialize
|
11
|
+
# Inicializa los diferentes atributos de la clase
|
12
|
+
|
13
|
+
def initialize(nombre, alimentos, peso, peso_total, cal_array, emisiones_array)
|
14
|
+
@nombre = nombre
|
15
|
+
@alimentos = alimentos
|
16
|
+
@peso = peso
|
17
|
+
@peso_total = peso_total
|
18
|
+
@cal_array = cal_array
|
19
|
+
@emisiones_array = emisiones_array
|
20
|
+
end
|
21
|
+
|
22
|
+
# Método porcentaje
|
23
|
+
# Calcula, segun los atributos dados, el porcentaje de proteinas, lipidos o carbohidratos
|
24
|
+
# @return: devuelve el porcentaje requerido
|
25
|
+
|
26
|
+
def porcentaje(alimentos, peso, peso_total)
|
27
|
+
total=0
|
28
|
+
i=0
|
29
|
+
while i<alimentos.length do
|
30
|
+
aux = alimentos[i] * peso[i]
|
31
|
+
total += aux
|
32
|
+
i+=1
|
33
|
+
end
|
34
|
+
|
35
|
+
return ((total/peso_total)*100).round(1)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Método cal_plato
|
39
|
+
# Método para hallar las calorias que posee un plato
|
40
|
+
# @return: Devuelve las calorias del plato
|
41
|
+
def cal_plato
|
42
|
+
cal_plato=0
|
43
|
+
i=0
|
44
|
+
|
45
|
+
while i < cal_array.length do
|
46
|
+
cal_plato += cal_array[i]
|
47
|
+
i += 1
|
48
|
+
end
|
49
|
+
return cal_plato
|
50
|
+
end
|
51
|
+
|
52
|
+
# Método to_s
|
53
|
+
# Método para sacar informacion formateada
|
54
|
+
# @return: Devuelve los datos formateados
|
55
|
+
def to_s
|
56
|
+
return "Plato: #{nombre}, Partes: #{alimentos}, Peso total: #{peso_total}"
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
#Clase plato_ heredada de clase platos
|
63
|
+
|
64
|
+
class Plato_ < Platos
|
65
|
+
|
66
|
+
attr_reader :cal_total
|
67
|
+
|
68
|
+
# Método initialize
|
69
|
+
# Método para inicializar los diferentes atributos de la clase
|
70
|
+
|
71
|
+
def initialize(nombre, alimentos, peso, peso_total, cal_array, emisiones_array)
|
72
|
+
|
73
|
+
super(nombre, alimentos, peso, peso_total, cal_array, emisiones_array)
|
74
|
+
|
75
|
+
@cal_plato = cal_plato
|
76
|
+
@emisiones_plato = emisiones_plato
|
77
|
+
@huella = huella
|
78
|
+
end
|
79
|
+
|
80
|
+
# Método emisiones_plato
|
81
|
+
# Método para calcular la cantidad de emisiones generadas en la realización de un plato
|
82
|
+
# @return: Devuelve las emisiones totales de un plato
|
83
|
+
def emisiones_plato
|
84
|
+
emisiones_plato=0
|
85
|
+
i=0
|
86
|
+
|
87
|
+
while i < emisiones_array.length do
|
88
|
+
emisiones_plato += emisiones_array[i]
|
89
|
+
i += 1
|
90
|
+
end
|
91
|
+
return emisiones_plato
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
# Método huella
|
97
|
+
# Método para hallar la huella nutricional de cada plato
|
98
|
+
# @return: Devuelve la huella generada; un valor comprendido entre 1 y 3
|
99
|
+
|
100
|
+
def huella
|
101
|
+
@huella_e
|
102
|
+
|
103
|
+
if @cal_plato <= 670
|
104
|
+
@huella_e = 1.0
|
105
|
+
elsif @cal_plato > 670 && @cal_plato <= 830
|
106
|
+
@huella_e = 2.0
|
107
|
+
else
|
108
|
+
@huella_e = 3.0
|
109
|
+
end
|
110
|
+
|
111
|
+
@huella_c
|
112
|
+
|
113
|
+
if @emisiones_plato <= 670
|
114
|
+
@huella_c = 1.0
|
115
|
+
elsif @emisiones_plato > 670 && @emisiones_plato <= 830
|
116
|
+
@huella_c = 2.0
|
117
|
+
else
|
118
|
+
@huella_c = 3.0
|
119
|
+
end
|
120
|
+
|
121
|
+
return (@huella_e+@huella_c)/2
|
122
|
+
end
|
123
|
+
|
124
|
+
# Método suma
|
125
|
+
# Método anteriormente utilizado para calcular todas las sumas, que ahora solo ocupa la suma del terreno ocupado
|
126
|
+
# @return: La suma del array de entrada
|
127
|
+
|
128
|
+
def suma(alimentos)
|
129
|
+
total=0
|
130
|
+
i=0
|
131
|
+
|
132
|
+
while i<alimentos.length do
|
133
|
+
total += alimentos[i]
|
134
|
+
i+=1
|
135
|
+
end
|
136
|
+
return total
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
# Método to_s
|
141
|
+
# Método para sacar informacion formateada
|
142
|
+
|
143
|
+
def to_s
|
144
|
+
return "Eficiencia = #{cal_plato}"
|
145
|
+
end
|
146
|
+
|
147
|
+
# Método <=>
|
148
|
+
# Método para comparar la eficiencia energética entre platos
|
149
|
+
|
150
|
+
def <=>(other)
|
151
|
+
@cal_plato <=> other.cal_plato
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|