alimento-alu0100948226 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 +12 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/Gemfile +8 -0
- data/Guardfile +82 -0
- data/README.md +35 -0
- data/Rakefile +16 -0
- data/alimento.gemspec +39 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/.yardoc/checksums +0 -0
- data/docs/.yardoc/complete +0 -0
- data/docs/.yardoc/object_types +0 -0
- data/docs/.yardoc/objects/root.dat +0 -0
- data/docs/.yardoc/proxy_types +0 -0
- data/docs/Alimento.html +178 -0
- data/docs/Alimento/AlimentoClas.html +394 -0
- data/docs/Alimento/Alimentos.html +734 -0
- data/docs/Alimento/Dll.html +925 -0
- data/docs/Alimento/Nodo.html +494 -0
- data/docs/_index.html +151 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +492 -0
- data/docs/file.README.html +117 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +117 -0
- data/docs/js/app.js +248 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +251 -0
- data/docs/top-level-namespace.html +110 -0
- data/lib/alimento.rb +50 -0
- data/lib/alimento/alimento_clasificado.rb +29 -0
- data/lib/alimento/alimentos.rb +49 -0
- data/lib/alimento/array.rb +33 -0
- data/lib/alimento/dll.rb +112 -0
- data/lib/alimento/plato.rb +115 -0
- data/lib/alimento/version.rb +3 -0
- data/pec +35 -0
- metadata +185 -0
@@ -0,0 +1,110 @@
|
|
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.9
|
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="Alimento.html" title="Alimento (module)">Alimento</a></span>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
</p>
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<div id="footer">
|
103
|
+
Generated on Fri Nov 17 11:01:03 2017 by
|
104
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
105
|
+
0.9.9 (ruby-2.3.1).
|
106
|
+
</div>
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</body>
|
110
|
+
</html>
|
data/lib/alimento.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require "alimento/version"
|
2
|
+
require "alimento/dll"
|
3
|
+
require "alimento/alimentos"
|
4
|
+
require "alimento/alimento_clasificado"
|
5
|
+
require "alimento/array"
|
6
|
+
require "alimento/plato"
|
7
|
+
|
8
|
+
module Alimento
|
9
|
+
@@tablaAlimento = [
|
10
|
+
AlimentoClas.new("Huevo frito", 14.1, 0.0, 19.5, "Huevos,lácteos y helados"),
|
11
|
+
AlimentoClas.new("Leche Vaca", 3.3, 4.8, 3.2, "Huevos,lácteos y helados"),
|
12
|
+
AlimentoClas.new("Yogurt", 3.8, 4.9, 3.8, "Huevos,lácteos y helados"),
|
13
|
+
AlimentoClas.new("Cerdo", 21.5, 0.0, 6.3, "Carnes y derivados"),
|
14
|
+
AlimentoClas.new("Ternera", 21.1, 0.0, 3.1, "Carnes y derivados"),
|
15
|
+
AlimentoClas.new("Pollo", 20.6, 0.0, 3.8, "Carnes y derivados"),
|
16
|
+
AlimentoClas.new("Bacalao", 17.7, 0.0, 0.4, "Pescados y mariscos"),
|
17
|
+
AlimentoClas.new("Atún", 21.5, 0.0, 15.5, "Pescados y mariscos"),
|
18
|
+
AlimentoClas.new("Salmón", 19.9, 0.0, 13.6, "Pescados y mariscos"),
|
19
|
+
AlimentoClas.new("Aceite de oliva", 0.0, 0.2 , 99.6, "Alimentos grasos"),
|
20
|
+
AlimentoClas.new("Mantequilla", 0.7, 0.0 , 83.2, "Alimentos grasos"),
|
21
|
+
AlimentoClas.new("Chocolate", 5.3, 47.0 , 30.0, "Alimentos grasos"),
|
22
|
+
AlimentoClas.new("Azúcar", 0.0, 99.8, 0.0, "Alimentos ricos en carbohidratos"),
|
23
|
+
AlimentoClas.new("Arroz", 6.8, 77.7, 0.6, "Alimentos ricos en carbohidratos"),
|
24
|
+
AlimentoClas.new("Lentejas", 23.5, 52.0, 1.4, "Alimentos ricos en carbohidratos"),
|
25
|
+
AlimentoClas.new("Papas", 2.0, 15.4, 0.1, "Alimentos ricos en carbohidratos"),
|
26
|
+
AlimentoClas.new("Tomate", 1.0, 3.5, 0.2, "Verduras y hortalizas"),
|
27
|
+
AlimentoClas.new("Cebolla", 1.3, 5.8, 0.3, "Verduras y hortalizas"),
|
28
|
+
AlimentoClas.new("Calabaza", 1.1, 4.8, 0.1, "Verduras y hortalizas"),
|
29
|
+
AlimentoClas.new("Manzana", 0.3, 12.4, 0.4, "Frutas"),
|
30
|
+
AlimentoClas.new("Plátano", 1.2, 21.4, 0.2, "Frutas"),
|
31
|
+
AlimentoClas.new("Pera", 0.5, 12.7, 0.3, "Frutas")
|
32
|
+
]
|
33
|
+
@@porcion = {
|
34
|
+
"piezas pequeñas " => 50,
|
35
|
+
"tazas " => 200,
|
36
|
+
"cucharon " => 120,
|
37
|
+
"piezas " => 100,
|
38
|
+
"cucharada " => 30
|
39
|
+
}
|
40
|
+
# encoding: utf-8
|
41
|
+
# Este módulo se ha creado para describir
|
42
|
+
# alimentos haciendo uso del Lenguaje de Programación Ruby.
|
43
|
+
# Es parte de las prácticas de la asignatura
|
44
|
+
# Lenguajes y Paradigmas de la Programación
|
45
|
+
#
|
46
|
+
#
|
47
|
+
# Author:: Gabriel Alejandro Rodríguez de Abreu (mailto:alu0100948226@ull.edu.es)
|
48
|
+
# Copyright:: Cretive Commons
|
49
|
+
# License:: Distributes under the same terms as Ruby
|
50
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
require "alimento/alimentos"
|
3
|
+
|
4
|
+
module Alimento
|
5
|
+
|
6
|
+
class AlimentoClas < Alimento::Alimentos
|
7
|
+
include Comparable
|
8
|
+
attr_reader :tipo
|
9
|
+
|
10
|
+
# Crea un alimento clasificado con su tipo.
|
11
|
+
# También llama al constructor de la clase padre Alimento,
|
12
|
+
# dotándole de nombre y valores para los nutrientes
|
13
|
+
def initialize(nombre, proteinas,glucidos,lipidos, tipo)
|
14
|
+
super(nombre,proteinas,glucidos,lipidos)
|
15
|
+
@tipo = tipo
|
16
|
+
end
|
17
|
+
|
18
|
+
# Incluido para poder usar los métodos del mixin Comparable
|
19
|
+
def <=>(another)
|
20
|
+
compare = super(another)
|
21
|
+
if compare == 0
|
22
|
+
return @tipo <=> another.tipo
|
23
|
+
else
|
24
|
+
return compare
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Alimento
|
2
|
+
# Constante que representa el valor energético que se obtiene de los glúcidos de un alimento
|
3
|
+
VAL_EN_GLUCIDOS = 4
|
4
|
+
|
5
|
+
# Constante que representa el valor energético que se obtiene de los lípidos de un alimento
|
6
|
+
VAL_EN_LIPIDOS = 9
|
7
|
+
|
8
|
+
# Constante que representa el valor energético que se obtiene de las proteinas de un alimento
|
9
|
+
VAL_EN_PROTEINAS = 4
|
10
|
+
|
11
|
+
|
12
|
+
class Alimentos
|
13
|
+
include Comparable
|
14
|
+
attr_reader :nombre, :proteinas, :glucidos, :lipidos
|
15
|
+
|
16
|
+
# Se asigna el nombre, y la cantidad de proteínas, glúcidos y lípidos del alimento
|
17
|
+
def initialize(nombre, proteinas, glucidos, lipidos)
|
18
|
+
@nombre = nombre
|
19
|
+
@proteinas = proteinas
|
20
|
+
@glucidos = glucidos
|
21
|
+
@lipidos = lipidos
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
# Operador de salida de la clase alimento.
|
26
|
+
# Muestra el alimento con formato:
|
27
|
+
# Nombre Cantidad_de_Proteínas Cantidad_de_glúcidos Cantidad_de_lípidos
|
28
|
+
# Ej: Huevos fritos 14.1 0.0 19.5
|
29
|
+
def to_s
|
30
|
+
"#{@nombre}\t#{@proteinas}\t#{@glucidos}\t#{@lipidos}"
|
31
|
+
end
|
32
|
+
|
33
|
+
# Calcula y devuelve el valor energético del alimento
|
34
|
+
def calcValEn
|
35
|
+
(@proteinas * VAL_EN_PROTEINAS) + (@glucidos * VAL_EN_GLUCIDOS) + (@lipidos * VAL_EN_LIPIDOS)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Incluido para poder utilizar los métodos del mixin Comparable
|
39
|
+
def <=>(another)
|
40
|
+
compare = calcValEn <=> another.calcValEn
|
41
|
+
if compare == 0
|
42
|
+
return @nombre <=> another.nombre
|
43
|
+
else
|
44
|
+
return compare
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
sub = lambda {self.each { |x| self.select{ |y| y <= x}.sortEach }}
|
3
|
+
|
4
|
+
class Array
|
5
|
+
def print
|
6
|
+
puts "["
|
7
|
+
self.each {|x| puts x}
|
8
|
+
puts "]"
|
9
|
+
end
|
10
|
+
|
11
|
+
def sortEach
|
12
|
+
v = self
|
13
|
+
v.each { min = v.min; return rest = v.select {|x| x == min} + v.select{ |x| x > min}.sortEach; }
|
14
|
+
end
|
15
|
+
|
16
|
+
def nSort
|
17
|
+
self.sort
|
18
|
+
end
|
19
|
+
|
20
|
+
def sortFor
|
21
|
+
v = self
|
22
|
+
for i in (0..v.size-1).to_a do
|
23
|
+
min = i
|
24
|
+
for j in (i..v.size-1).to_a do
|
25
|
+
if v[j] < v[min]
|
26
|
+
min = j
|
27
|
+
end
|
28
|
+
end
|
29
|
+
v[i],v[min] = v[min],v[i]
|
30
|
+
end
|
31
|
+
v
|
32
|
+
end
|
33
|
+
end
|
data/lib/alimento/dll.rb
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
|
2
|
+
module Alimento
|
3
|
+
|
4
|
+
# Clase nodo, almacena un valor y apunta al nodo anterior y al siguiente. Es necesaria para la clase Dll
|
5
|
+
Nodo = Struct.new(:value, :next, :prev)
|
6
|
+
class Nodo
|
7
|
+
# Operador de salida de la clase nodo. Imprime únicamente el valor del nodo
|
8
|
+
def to_s
|
9
|
+
value.to_s
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
class Dll
|
16
|
+
include Enumerable
|
17
|
+
attr_reader :head, :tail
|
18
|
+
|
19
|
+
# Crea una lista doblemente enlazada.
|
20
|
+
# Si toma un nodo de argumento apunta la cabeza y cola al mismo,
|
21
|
+
# si no, la crea vacía.
|
22
|
+
def initialize( nodo = nil )
|
23
|
+
@head = nodo
|
24
|
+
@tail = nodo
|
25
|
+
end
|
26
|
+
|
27
|
+
# Inserta el valor al inicio de la lista
|
28
|
+
def insertarDelante(valor)
|
29
|
+
nodo = Nodo.new(valor,nil,nil)
|
30
|
+
if @head == nil
|
31
|
+
@head = nodo
|
32
|
+
@tail = nodo
|
33
|
+
else
|
34
|
+
nodo.next = @head
|
35
|
+
@head.prev = nodo
|
36
|
+
@head = nodo
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Inserta el valor al final de la lista
|
41
|
+
def insertarDetras(valor)
|
42
|
+
nodo = Nodo.new(valor,nil,nil)
|
43
|
+
if @tail == nil
|
44
|
+
@head = nodo
|
45
|
+
@tail = nodo
|
46
|
+
else
|
47
|
+
nodo.prev = @tail
|
48
|
+
@tail.next = nodo
|
49
|
+
@tail = nodo
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Elimina de la lista el último valor
|
54
|
+
def extraerUltimo
|
55
|
+
if @tail != nil
|
56
|
+
@tail = @tail.prev
|
57
|
+
@tail.next = nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Elimina de la lista el primer valor
|
62
|
+
def extraerPrimero
|
63
|
+
if @head != nil
|
64
|
+
@head = @head.next
|
65
|
+
@head.prev = nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Busca el primer nodo con el valor especificado y se elimina
|
70
|
+
def extraer(nodo)
|
71
|
+
if nodo == @head
|
72
|
+
extraerPrimero
|
73
|
+
elsif nodo == @tail
|
74
|
+
extraerUltimo
|
75
|
+
else
|
76
|
+
tmp = @head
|
77
|
+
while tmp != nodo
|
78
|
+
tmp = tmp.next
|
79
|
+
end
|
80
|
+
if tmp == nodo
|
81
|
+
tmp.prev.next = tmp.next
|
82
|
+
tmp.next.prev = tmp.prev
|
83
|
+
tmp.prev == nil
|
84
|
+
tmp.next == nil
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Operador de salida de la Lista Doblemente enlazada
|
90
|
+
def to_s
|
91
|
+
if @head != nil
|
92
|
+
temp = @head
|
93
|
+
temp.value.to_s
|
94
|
+
while temp.next != nil
|
95
|
+
temp = temp.next
|
96
|
+
temp.value.to_s
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Incluido para poder utilizar los métodos mixin de Enumerable para
|
102
|
+
# la Lista Doblemente Enlazada.
|
103
|
+
def each
|
104
|
+
tmp = self.head
|
105
|
+
while tmp != nil
|
106
|
+
yield tmp.value
|
107
|
+
tmp = tmp.next
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require "alimento/alimento_clasificado"
|
2
|
+
module Alimento
|
3
|
+
class Plato
|
4
|
+
attr_accessor :name, :vegetales, :frutas, :integrales, :proteinas, :aceites, :bebidas
|
5
|
+
|
6
|
+
def initialize(name, &block)
|
7
|
+
@name = name
|
8
|
+
@vegetales = []
|
9
|
+
@frutas = []
|
10
|
+
@integrales = []
|
11
|
+
@proteinas = []
|
12
|
+
@aceites = []
|
13
|
+
@bebidas = []
|
14
|
+
|
15
|
+
if block_given?
|
16
|
+
if block.arity == 1
|
17
|
+
yield self
|
18
|
+
else
|
19
|
+
instance_eval(&block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def vegetal( nombre, opcion = {})
|
25
|
+
veg = procesar(nombre, opcion)
|
26
|
+
vegetales << veg
|
27
|
+
end
|
28
|
+
|
29
|
+
def fruta( nombre, opcion = {})
|
30
|
+
frut = procesar(nombre, opcion)
|
31
|
+
frutas << frut
|
32
|
+
end
|
33
|
+
|
34
|
+
def cereal( nombre, opcion = {})
|
35
|
+
int = procesar(nombre, opcion)
|
36
|
+
integrales << int
|
37
|
+
end
|
38
|
+
|
39
|
+
def proteina( nombre, opcion = {})
|
40
|
+
prot = procesar(nombre, opcion)
|
41
|
+
proteinas << prot
|
42
|
+
end
|
43
|
+
|
44
|
+
def aceite( nombre, opcion = {})
|
45
|
+
ac = procesar(nombre, opcion)
|
46
|
+
aceites << ac
|
47
|
+
end
|
48
|
+
|
49
|
+
def bebida( nombre, opcion = {})
|
50
|
+
beb = procesar(nombre, opcion)
|
51
|
+
bebidas << beb
|
52
|
+
end
|
53
|
+
|
54
|
+
def procesar(nombre, opcion)
|
55
|
+
if opcion[:porcion]
|
56
|
+
c_array = opcion[:porcion].split(' ')
|
57
|
+
mult_arr = c_array[0].split('/')
|
58
|
+
if mult_arr.length == 2
|
59
|
+
mult = mult_arr[0].to_f / mult_arr[1].to_f
|
60
|
+
else
|
61
|
+
mult = mult_arr[0].to_f
|
62
|
+
end
|
63
|
+
h_search = ""
|
64
|
+
c_array.each_with_index {|el, i| if i > 0; h_search = h_search + el + "( |s )"; end }
|
65
|
+
s = @@porcion.keys.grep %r[#{h_search}]
|
66
|
+
prop = @@porcion[s[0]]
|
67
|
+
val_en_std = 0;
|
68
|
+
al = @@tablaAlimento.find { |alimento| alimento.nombre == nombre }
|
69
|
+
val_en_std = al.calcValEn if al
|
70
|
+
val_en_total = mult * prop * (val_en_std.to_f / 100.0)
|
71
|
+
elemento = [nombre, val_en_total]
|
72
|
+
elsif opcion[:gramos]
|
73
|
+
val_en_std = 0;
|
74
|
+
al = @@tablaAlimento.find { |alimento| alimento.nombre == nombre }
|
75
|
+
val_en_std = al.calcValEn if al
|
76
|
+
val_total = (opcion[:gramos] * val_en_std).to_f / 100
|
77
|
+
elemento = [nombre, val_total]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def to_s
|
82
|
+
output = @name
|
83
|
+
output << "\n#{'=' * @name.size}"
|
84
|
+
veg = frut = cer = prot = ac = beb = 0
|
85
|
+
@vegetales.each {|x| veg += x[1]}
|
86
|
+
@frutas.each {|x| frut += x[1]}
|
87
|
+
@integrales.each {|x| cer += x[1]}
|
88
|
+
@proteinas.each {|x| prot += x[1]}
|
89
|
+
@aceites.each {|x| ac += x[1]}
|
90
|
+
@bebidas.each {|x| beb += x[1]}
|
91
|
+
|
92
|
+
total = veg + frut + cer + prot + ac + beb
|
93
|
+
output << "\n\nVegetales:\t#{veg.round(2)}\t#{(100*veg/total).round(2)}%\n\n "
|
94
|
+
@vegetales.each { |x| output << @@tablaAlimento.find{ |i| x[0] == i.nombre}.to_s; output << "\t#{x[1].round(2)}\n "}
|
95
|
+
|
96
|
+
output << "\n\nFrutas:\t#{frut.round(2)}\t#{(100*frut/total).round(2)}%\n\n "
|
97
|
+
@frutas.each { |x| output << @@tablaAlimento.find{ |i| x[0] == i.nombre}.to_s; output << "\t#{x[1].round(2)}\n "}
|
98
|
+
|
99
|
+
output << "\n\nCereales:\t#{cer.round(2)}\t#{(100*cer/total).round(2)}%\n\n "
|
100
|
+
@integrales.each { |x| output << @@tablaAlimento.find{ |i| x[0] == i.nombre}.to_s; output << "\t#{x[1].round(2)}\n "}
|
101
|
+
|
102
|
+
output << "\n\nProteinas:\t#{prot.round(2)}\t#{(100*prot/total).round(2)}%\n\n "
|
103
|
+
@proteinas.each { |x| output << @@tablaAlimento.find{ |i| x[0] == i.nombre}.to_s; output << "\t#{x[1].round(2)}\n "}
|
104
|
+
|
105
|
+
output << "\n\nAceites:\t#{ac.round(2)}\t#{(100*ac/total).round(2)}%\n\n "
|
106
|
+
@aceites.each { |x| output << @@tablaAlimento.find{ |i| x[0] == i.nombre}.to_s; output << "\t#{x[1].round(2)}\n "}
|
107
|
+
|
108
|
+
output << "\n\nBebidas:\t#{beb.round(2)}\t#{(100*beb/total).round(2)}%\n\n "
|
109
|
+
@bebidas.each { |x| output << @@tablaAlimento.find{ |i| x[0] == i.nombre}.to_s; output << "\t#{x[1].round(2)}\n "}
|
110
|
+
|
111
|
+
output << "\n\nTotal: #{total.round(2)}"
|
112
|
+
output
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|