Alimento0100956269 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/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Alimento.gemspec +39 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/Guardfile +82 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +7 -0
- data/_config.yml +1 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/Alimento.html +117 -0
- data/docs/Comida.html +1075 -0
- data/docs/Comida_clasif.html +396 -0
- data/docs/List.html +1062 -0
- data/docs/Node.html +409 -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 +126 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +126 -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 +299 -0
- data/docs/top-level-namespace.html +112 -0
- data/lib/Alimento.rb +9 -0
- data/lib/Alimento/Comida.rb +169 -0
- data/lib/Alimento/List.rb +152 -0
- data/lib/Alimento/Plato.rb +160 -0
- data/lib/Alimento/version.rb +3 -0
- metadata +181 -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.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
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Comida.html" title="Comida (class)">Comida</a></span>, <span class='object_link'><a href="Comida_clasif.html" title="Comida_clasif (class)">Comida_clasif</a></span>, <span class='object_link'><a href="List.html" title="List (class)">List</a></span>, <span class='object_link'><a href="Node.html" title="Node (class)">Node</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 Nov 15 11:43:17 2017 by
|
106
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
107
|
+
0.9.9 (ruby-2.3.1).
|
108
|
+
</div>
|
109
|
+
|
110
|
+
</div>
|
111
|
+
</body>
|
112
|
+
</html>
|
data/lib/Alimento.rb
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Author:: Juan Carlos González Pascolo (mailto:alu0100956269@ull.edu.es)
|
3
|
+
# Copyright:: Cretive Commons
|
4
|
+
# License:: Distributes under the same terms as Ruby
|
5
|
+
|
6
|
+
#Esta clase permite ver los distintos componentes de un alimento y su valor energético
|
7
|
+
#Se ha incluido el mixin Comparable
|
8
|
+
class Comida
|
9
|
+
include Comparable
|
10
|
+
|
11
|
+
#Getters de las distintas variables de instancia
|
12
|
+
attr_reader :name, :proteins, :carbohydrates, :lipids
|
13
|
+
attr_accessor :g
|
14
|
+
|
15
|
+
#Se asignan los valores que debe tener el alimento, es decir,
|
16
|
+
#su nombre, numero de proteinas, glúcidos (carbohidratos) y lípidos
|
17
|
+
def initialize (name_value, proteins_value, carbohydrates_value, lipids_value)
|
18
|
+
@name = name_value
|
19
|
+
@proteins = proteins_value
|
20
|
+
@carbohydrates = carbohydrates_value
|
21
|
+
@lipids = lipids_value
|
22
|
+
@g = nil
|
23
|
+
end
|
24
|
+
#--
|
25
|
+
#<<<<<<< HEAD
|
26
|
+
#++
|
27
|
+
#Función to_string
|
28
|
+
def to_s
|
29
|
+
"p: #{@proteins}, c: #{@carbohydrates}, l: #{@lipids}"
|
30
|
+
end
|
31
|
+
#--
|
32
|
+
#======= hecho por el merge
|
33
|
+
#++
|
34
|
+
#Función que devuelve las kcalorias del alimento por su número de proteinas
|
35
|
+
def format_proteins
|
36
|
+
proteins_kcal = @proteins * 4
|
37
|
+
return proteins_kcal
|
38
|
+
end
|
39
|
+
|
40
|
+
#Función que devuelve las kcalorias del alimento por su número de glúcidos
|
41
|
+
def format_ch
|
42
|
+
ch_kcal = @carbohydrates * 4
|
43
|
+
return ch_kcal
|
44
|
+
end
|
45
|
+
|
46
|
+
#Función que devuelve las kcalorias del alimento por su número de lípidos
|
47
|
+
def format_lipids
|
48
|
+
lipids_kcal = @lipids * 9
|
49
|
+
return lipids_kcal
|
50
|
+
end
|
51
|
+
|
52
|
+
#Función que devuelve las kcalorias totales del alimento
|
53
|
+
def val_energ
|
54
|
+
@energ_val = format_proteins + format_ch + format_lipids
|
55
|
+
return @energ_val
|
56
|
+
end
|
57
|
+
#--
|
58
|
+
#>>>>>>> desarrollo
|
59
|
+
#++
|
60
|
+
|
61
|
+
#Metodo que convierte a string los componentes del alimento en kcaloría y su valor energético total
|
62
|
+
def show_ev
|
63
|
+
"The fortmated values are: p->#{format_proteins}, c->#{format_ch}, l->#{format_lipids}; The energ. value is -> #{val_energ} kcal"
|
64
|
+
end
|
65
|
+
|
66
|
+
# Se define para incluir el mixin comparable
|
67
|
+
# Se toma como valor para la comparación el valor energético
|
68
|
+
# y para saber si son iguales también se toma el nombre.
|
69
|
+
def <=>(other_food)
|
70
|
+
return nil unless other_food.is_a?Comida
|
71
|
+
val_energ <=> other_food.val_energ
|
72
|
+
end
|
73
|
+
|
74
|
+
#para comparar se debe pasar otra comida como argumento
|
75
|
+
def ==(other_food)
|
76
|
+
return nil unless other_food.is_a?Comida
|
77
|
+
(@name == other_food.name) && (val_energ == other_food.val_energ)
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
def aibc_imperative
|
82
|
+
i = 0
|
83
|
+
r = []
|
84
|
+
while i < @g.size
|
85
|
+
index = 1
|
86
|
+
s = []
|
87
|
+
while index < @g[i].size
|
88
|
+
if @g[i][index] < @g[i][0]
|
89
|
+
s << 0.0
|
90
|
+
else
|
91
|
+
s << (((@g[i][index] - @g[i][0]) + (@g[i][index-1] - @g[i][0]))/2)*5
|
92
|
+
end
|
93
|
+
index = index + 1
|
94
|
+
end
|
95
|
+
r << s
|
96
|
+
i = i + 1
|
97
|
+
end
|
98
|
+
|
99
|
+
suma = []
|
100
|
+
j = 0
|
101
|
+
while j < @g.size
|
102
|
+
k = 0
|
103
|
+
s = 0
|
104
|
+
while k < r[j].size
|
105
|
+
s = s + r[j][k]
|
106
|
+
k = k + 1
|
107
|
+
end
|
108
|
+
suma << s
|
109
|
+
j = j + 1
|
110
|
+
end
|
111
|
+
suma
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
def aibc_funcional
|
116
|
+
|
117
|
+
r =[]
|
118
|
+
arr = []
|
119
|
+
@g.collect{
|
120
|
+
|x|
|
121
|
+
x.each_with_index{|y, index|
|
122
|
+
if(index != 0)
|
123
|
+
if(y<x[0])
|
124
|
+
arr[index-1]=0.0
|
125
|
+
else
|
126
|
+
arr[index-1] = ((((x[index]-x[0]) + (x[index-1]-x[0]))/2)*5)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
}
|
130
|
+
r.push(arr.reduce(:+))
|
131
|
+
}
|
132
|
+
r
|
133
|
+
|
134
|
+
=begin
|
135
|
+
ge = (0...@g[0].size).to_a.zip(@g[0], @g[1])
|
136
|
+
puts "#{ge}"
|
137
|
+
@g.each_with_index{
|
138
|
+
|x, index|
|
139
|
+
if (index != 0)
|
140
|
+
if (x[index] < x[0])
|
141
|
+
(((x[index]-@g[0]) + (x[index-1]-x[0]))/2)*5
|
142
|
+
end
|
143
|
+
end
|
144
|
+
}
|
145
|
+
=end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
#Clase derivada, en la cual se añade el tipo de alimento que es.
|
151
|
+
class Comida_clasif < Comida
|
152
|
+
#para que se pueda tener el getter del tipo de alimento
|
153
|
+
attr_reader :type
|
154
|
+
|
155
|
+
#Llama al initialize de su clase padre para todos los valores menos para el tipo,
|
156
|
+
#que se asigna en esta clase
|
157
|
+
def initialize(name_value, proteins_value, carbohydrates_value, lipids_value, type_value)
|
158
|
+
super(name_value, proteins_value, carbohydrates_value, lipids_value)
|
159
|
+
@type = type_value
|
160
|
+
end
|
161
|
+
|
162
|
+
#metodo to_string que añade, al principio, al string de la clase padre el tipo de alimento que es
|
163
|
+
def to_s
|
164
|
+
out = "#{@name} belong to #{@type} and its qualities are "
|
165
|
+
out << super.to_s
|
166
|
+
return out
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
@@ -0,0 +1,152 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Author:: Juan Carlos González Pascolo (mailto:alu0100956269@ull.edu.es)
|
3
|
+
# Copyright:: Cretive Commons
|
4
|
+
# License:: Distributes under the same terms as Ruby
|
5
|
+
|
6
|
+
# create a Struct with :value, :next and :prev
|
7
|
+
Node = Struct.new(:value, :next, :prev)
|
8
|
+
|
9
|
+
#Esta clase implementa una lista doblemente enlazada
|
10
|
+
#Se ha incluido el mixin Enumerable
|
11
|
+
|
12
|
+
class List
|
13
|
+
include Enumerable
|
14
|
+
|
15
|
+
#Getters de las distintas variables de instancia
|
16
|
+
attr_reader :head, :tale, :num_elem
|
17
|
+
|
18
|
+
#Con el primer valor que nos pasen creamos el nodo inicial que es head y tale de las lista.
|
19
|
+
#La lista ya tiene un elemento por tanto el numero de elementos es 1
|
20
|
+
def initialize (node)
|
21
|
+
@head = Node.new(node,nil,nil)
|
22
|
+
@tale = @head
|
23
|
+
@num_elem = 1
|
24
|
+
end
|
25
|
+
|
26
|
+
#Función to_string, que solo muestra el nombre de los valores (los alimentos)
|
27
|
+
def to_s
|
28
|
+
aux="{"
|
29
|
+
node = Node.new
|
30
|
+
node = @head
|
31
|
+
while (node != tale) do
|
32
|
+
aux += node.value.name
|
33
|
+
aux += ", "
|
34
|
+
node = node.next
|
35
|
+
end
|
36
|
+
aux += node.value.name
|
37
|
+
aux += "}"
|
38
|
+
return aux
|
39
|
+
end
|
40
|
+
|
41
|
+
#Metodo para insertar un valor por la cola
|
42
|
+
def insert_tale(node)
|
43
|
+
insertnode = Node.new(node,nil,@tale)
|
44
|
+
@tale.next = insertnode
|
45
|
+
@tale = insertnode
|
46
|
+
@num_elem += 1
|
47
|
+
end
|
48
|
+
|
49
|
+
#Metodo para insertar un valor por el head
|
50
|
+
def insert_head(node)
|
51
|
+
insertnode = Node.new(node,@head,nil)
|
52
|
+
@head.prev = insertnode
|
53
|
+
@head = insertnode
|
54
|
+
@num_elem += 1
|
55
|
+
end
|
56
|
+
|
57
|
+
#Metodo para insertar más de un valor por la cola
|
58
|
+
def insert_mto_tale(node_array) #insert More Than One in tale
|
59
|
+
node_array.each do |food|
|
60
|
+
insert_tale(food)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
#Metodo para insertar más de un valor por la head
|
65
|
+
def insert_mto_head(node_array) #insert More Than One in head
|
66
|
+
node_array.each do |food|
|
67
|
+
insert_head(food)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
#Método para extraer el último elemento (el tale)
|
72
|
+
def extract_tale
|
73
|
+
extracted_node = Node.new
|
74
|
+
extracted_node = @tale
|
75
|
+
@tale = @tale.prev
|
76
|
+
@tale.next = nil
|
77
|
+
extracted_node.prev = nil
|
78
|
+
@num_elem -= 1
|
79
|
+
return extracted_node
|
80
|
+
end
|
81
|
+
|
82
|
+
#Método para extraer el primer elemento (el head)
|
83
|
+
def extract_head
|
84
|
+
extracted_node = Node.new
|
85
|
+
extracted_node = @head
|
86
|
+
@head = @head.next
|
87
|
+
@head.prev = nil
|
88
|
+
extracted_node.next = nil
|
89
|
+
@num_elem -= 1
|
90
|
+
return extracted_node
|
91
|
+
end
|
92
|
+
|
93
|
+
# Se incluye el metodo del mixin Enumerable
|
94
|
+
# Se define como una iteración cada uno de los valores de los nodos
|
95
|
+
def each
|
96
|
+
aux = Node.new
|
97
|
+
aux = @head
|
98
|
+
tam = @num_elem
|
99
|
+
for i in (1..tam)
|
100
|
+
yield aux.value
|
101
|
+
aux = aux.next
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
#Se usan los bucles for para ordenar la lista, esta programación NO es funcional
|
106
|
+
def for_sort
|
107
|
+
sort_list = [@head.value]
|
108
|
+
auxnode = @head
|
109
|
+
for i in(1...@num_elem)
|
110
|
+
auxnode = auxnode.next
|
111
|
+
for j in(0..sort_list.size)
|
112
|
+
if(j == sort_list.size)
|
113
|
+
sort_list.push(auxnode.value)
|
114
|
+
else
|
115
|
+
if(auxnode.value < sort_list[j])
|
116
|
+
sort_list.insert(j,auxnode.value)
|
117
|
+
break
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
return sort_list
|
123
|
+
end
|
124
|
+
|
125
|
+
def each_sort
|
126
|
+
sort_list = [@head.value]
|
127
|
+
self.each_with_index do
|
128
|
+
|x, pos|
|
129
|
+
if(pos != 0)
|
130
|
+
sort_list.each_with_index do
|
131
|
+
|y, index|
|
132
|
+
if (index == (sort_list.size - 1))
|
133
|
+
if(x < y)
|
134
|
+
sort_list.insert(index, x)
|
135
|
+
break
|
136
|
+
else
|
137
|
+
sort_list.push(x)
|
138
|
+
break
|
139
|
+
end
|
140
|
+
else
|
141
|
+
if(x < y)
|
142
|
+
sort_list.insert(index, x)
|
143
|
+
break
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
return sort_list
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
require 'Alimento'
|
2
|
+
|
3
|
+
class Plato
|
4
|
+
attr_accessor :name, :vegetales, :frutas, :cereales, :proteinas, :aceites
|
5
|
+
|
6
|
+
def initialize(name, &block)
|
7
|
+
@name = name
|
8
|
+
@vegetales = []
|
9
|
+
@frutas = []
|
10
|
+
@cereales = []
|
11
|
+
@proteinas = []
|
12
|
+
@aceites = []
|
13
|
+
@kcal_totales = 0
|
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
|
+
TOMATE = Comida_clasif.new("Tomate", 1.0, 3.5, 0.2, "verduras y hortalizas")
|
25
|
+
PLATANO = Comida_clasif.new("Plátano", 1.2, 21.4, 0.2, "frutas")
|
26
|
+
ARROZ = Comida_clasif.new("Arroz", 6.8, 77.7, 0.6, "alimentos ricos en carbohidratos")
|
27
|
+
LENTEJAS = Comida_clasif.new("Lentejas", 23.5, 52.0, 1.4, "alimentos ricos en carbohidratos")
|
28
|
+
HUEVO = Comida_clasif.new("Huevo", 14.1, 0.0, 19.5, "huevos, lacteos y helados")
|
29
|
+
ACEITE = Comida_clasif.new("Aceite de oliva", 0.0, 0.2, 99.6, "alimentos grasos")
|
30
|
+
|
31
|
+
ALIMENTOS = [TOMATE, PLATANO, ARROZ,LENTEJAS, HUEVO, ACEITE]
|
32
|
+
|
33
|
+
CANTIDAD = {' gramo' => 1, ' cucharada' => 2, ' cucharón' => 4, ' pieza pequeña' => 5, ' pieza mediana' => 7.5, ' pieza grande' => 10, ' taza' => 15}
|
34
|
+
|
35
|
+
def line (vector)
|
36
|
+
salida = ""
|
37
|
+
vector.each{
|
38
|
+
|value|
|
39
|
+
index = ALIMENTOS.find_index{ |obj| obj.name == value[0] }
|
40
|
+
salida << "\n#{ALIMENTOS[index].name}".ljust(16)
|
41
|
+
salida << " #{ALIMENTOS[index].carbohydrates}".ljust(15)
|
42
|
+
salida << " #{ALIMENTOS[index].proteins}".ljust(15)
|
43
|
+
salida << " #{ALIMENTOS[index].lipids}".ljust(15)
|
44
|
+
|
45
|
+
n_o_p = /[0-9]+/.match(value[1])[0].to_i #number_of_pieces
|
46
|
+
t_o_p = /\D+/.match(value[1]).to_s #type_of_piece
|
47
|
+
|
48
|
+
if(t_o_p == '/')
|
49
|
+
n_o_p = /[0-9]+\/[0-9]+/.match(value[1]).to_a
|
50
|
+
dividendo = n_o_p[0][0].to_f
|
51
|
+
|
52
|
+
puts dividendo
|
53
|
+
divisor = n_o_p[0][2].to_i
|
54
|
+
puts divisor
|
55
|
+
n_o_p = dividendo / divisor
|
56
|
+
|
57
|
+
t_o_p = /\D+/.match(value[1].tr('/','')).to_s
|
58
|
+
end
|
59
|
+
|
60
|
+
total_value = CANTIDAD[t_o_p] * n_o_p * ALIMENTOS[index].val_energ
|
61
|
+
@kcal_totales += total_value
|
62
|
+
salida << " %0.2f".ljust(15) % [total_value]
|
63
|
+
}
|
64
|
+
return salida
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def to_s
|
69
|
+
salida = @name
|
70
|
+
salida << "\n#{'=' * @name.size}\n\n"
|
71
|
+
salida << "Composición nutricional \n"
|
72
|
+
salida << "Nombre".ljust(15)
|
73
|
+
salida << "Glucidos".ljust(15)
|
74
|
+
salida << "Proteinas".ljust(15)
|
75
|
+
salida << "Lípidos".ljust(15)
|
76
|
+
salida << "Val.Energ.".ljust(15)
|
77
|
+
|
78
|
+
aux = line(@vegetales)
|
79
|
+
salida << "#{aux}"
|
80
|
+
|
81
|
+
aux = line(@frutas)
|
82
|
+
salida << "#{aux}"
|
83
|
+
|
84
|
+
aux = line(@cereales)
|
85
|
+
salida << "#{aux}"
|
86
|
+
|
87
|
+
aux = line(@proteinas)
|
88
|
+
salida << "#{aux}"
|
89
|
+
|
90
|
+
aux = line(@aceites)
|
91
|
+
salida << "#{aux}"
|
92
|
+
|
93
|
+
|
94
|
+
salida << "\n\n ".ljust(47)
|
95
|
+
salida << "kcal totales: %0.2f" % [@kcal_totales]
|
96
|
+
salida
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def vegetal(name, options = {})
|
101
|
+
vegetal = []
|
102
|
+
vegetal[0] = name
|
103
|
+
vegetal[1] = "#{options[:porcion]}" if options[:porcion]
|
104
|
+
@vegetales << vegetal
|
105
|
+
end
|
106
|
+
|
107
|
+
def fruta(name, options = {})
|
108
|
+
fruta = []
|
109
|
+
fruta[0] = name
|
110
|
+
fruta[1] = "#{options[:porcion]}" if options[:porcion]
|
111
|
+
@frutas << fruta
|
112
|
+
end
|
113
|
+
|
114
|
+
def cereal(name, options = {})
|
115
|
+
cereal = []
|
116
|
+
cereal[0] = name
|
117
|
+
cereal[1] = "#{options[:porcion]}" if options[:porcion]
|
118
|
+
@cereales << cereal
|
119
|
+
end
|
120
|
+
|
121
|
+
def proteina(name, options = {})
|
122
|
+
proteina = []
|
123
|
+
proteina[0] = name
|
124
|
+
proteina[1] = "#{options[:porcion]}" if options[:porcion]
|
125
|
+
@proteinas << proteina
|
126
|
+
end
|
127
|
+
|
128
|
+
def aceite(name, options = {})
|
129
|
+
aceite = []
|
130
|
+
aceite[0] = name
|
131
|
+
aceite[1] = "#{options[:porcion]}" if options[:porcion]
|
132
|
+
@aceites << aceite
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
=begin
|
139
|
+
Comida_clasif: LECHE = Comida_clasif.new("Leche", 3.3, 4.8, 3.2, "huevos, lacteos y helados")
|
140
|
+
Comida_clasif: YOGURT = Comida_clasif.new("Yogurt", 3.8, 4.9, 3.8, "huevos, lacteos y helados")
|
141
|
+
Comida_clasif: CERDO = Comida_clasif.new("Cerdo", 21.5, 0.0, 6.3, "carnes y derivados")
|
142
|
+
Comida_clasif: TERNERA = Comida_clasif.new("Ternera", 21.1, 0.0, 3.1, "carnes y derivados")
|
143
|
+
Comida_clasif: POLLO = Comida_clasif.new("Pollo", 20.6, 0.0, 5.6, "carnes y derivados")
|
144
|
+
Comida_clasif: BACALAO = Comida_clasif.new("Bacalao", 17.7, 0.0, 0.4, "pescados y mariscos")
|
145
|
+
@atun = Comida_clasif.new("Atun", 21.5, 0.0, 15.5, "pescados y mariscos")
|
146
|
+
@salmon = Comida_clasif.new("Salmon", 19.9, 0.0, 13.6, "pescados y mariscos")
|
147
|
+
@mantequilla = Comida_clasif.new("Mantequilla", 0.7, 0.0, 83.2, "alimentos grasos")
|
148
|
+
@chocolate = Comida_clasif.new("Chocolate", 5.3, 47.0, 30.0, "alimentos grasos")
|
149
|
+
@azucar = Comida_clasif.new("Azucar", 0.0, 99.8, 0.0, "alimentos ricos en carbohidratos")
|
150
|
+
@papas = Comida_clasif.new("Papas", 2.0, 15.4, 0.1, "alimentos ricos en carbohidratos")
|
151
|
+
@cebolla = Comida_clasif.new("Cebolla", 1.3, 5.8, 0.3, "verduras y hortalizas")
|
152
|
+
@calabaza = Comida_clasif.new("Calabaza", 1.1, 4.8, 0.1, "verduras y hortalizas")
|
153
|
+
@manzana = Comida_clasif.new("Manzana", 0.3, 12.4, 0.4, "frutas")
|
154
|
+
@pera = Comida_clasif.new("Pera", 0.5, 12.7, 0.3, "frutas")
|
155
|
+
=end
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
end
|