alu0101166858_plato 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +6 -0
  6. data/Guardfile +82 -0
  7. data/README.md +35 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/docs/Alimentos.html +420 -0
  12. data/docs/AlimentosCarbohidratos.html +102 -0
  13. data/docs/AlimentosGrasos.html +102 -0
  14. data/docs/Bebidas.html +102 -0
  15. data/docs/CarnesDerivados.html +102 -0
  16. data/docs/Frutas.html +102 -0
  17. data/docs/Gemfile.html +99 -0
  18. data/docs/Gemfile_lock.html +176 -0
  19. data/docs/Guardfile.html +176 -0
  20. data/docs/HuevosLacteosHelados.html +104 -0
  21. data/docs/List.html +459 -0
  22. data/docs/Node.html +203 -0
  23. data/docs/Object.html +116 -0
  24. data/docs/PescadosMariscos.html +102 -0
  25. data/docs/Prct06.html +109 -0
  26. data/docs/README_md.html +150 -0
  27. data/docs/Rakefile.html +97 -0
  28. data/docs/VerdurasHortalizas.html +102 -0
  29. data/docs/bin/setup.html +97 -0
  30. data/docs/created.rid +15 -0
  31. data/docs/css/fonts.css +167 -0
  32. data/docs/css/rdoc.css +590 -0
  33. data/docs/fonts/Lato-Light.ttf +0 -0
  34. data/docs/fonts/Lato-LightItalic.ttf +0 -0
  35. data/docs/fonts/Lato-Regular.ttf +0 -0
  36. data/docs/fonts/Lato-RegularItalic.ttf +0 -0
  37. data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
  38. data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
  39. data/docs/images/add.png +0 -0
  40. data/docs/images/arrow_up.png +0 -0
  41. data/docs/images/brick.png +0 -0
  42. data/docs/images/brick_link.png +0 -0
  43. data/docs/images/bug.png +0 -0
  44. data/docs/images/bullet_black.png +0 -0
  45. data/docs/images/bullet_toggle_minus.png +0 -0
  46. data/docs/images/bullet_toggle_plus.png +0 -0
  47. data/docs/images/date.png +0 -0
  48. data/docs/images/delete.png +0 -0
  49. data/docs/images/find.png +0 -0
  50. data/docs/images/loadingAnimation.gif +0 -0
  51. data/docs/images/macFFBgHack.png +0 -0
  52. data/docs/images/package.png +0 -0
  53. data/docs/images/page_green.png +0 -0
  54. data/docs/images/page_white_text.png +0 -0
  55. data/docs/images/page_white_width.png +0 -0
  56. data/docs/images/plugin.png +0 -0
  57. data/docs/images/ruby.png +0 -0
  58. data/docs/images/tag_blue.png +0 -0
  59. data/docs/images/tag_green.png +0 -0
  60. data/docs/images/transparent.png +0 -0
  61. data/docs/images/wrench.png +0 -0
  62. data/docs/images/wrench_orange.png +0 -0
  63. data/docs/images/zoom.png +0 -0
  64. data/docs/index.html +125 -0
  65. data/docs/js/darkfish.js +161 -0
  66. data/docs/js/jquery.js +4 -0
  67. data/docs/js/navigation.js +142 -0
  68. data/docs/js/navigation.js.gz +0 -0
  69. data/docs/js/search.js +109 -0
  70. data/docs/js/search_index.js +1 -0
  71. data/docs/js/search_index.js.gz +0 -0
  72. data/docs/js/searcher.js +228 -0
  73. data/docs/js/searcher.js.gz +0 -0
  74. data/docs/prct06_gemspec.html +130 -0
  75. data/docs/table_of_contents.html +203 -0
  76. data/lib/prct06.rb +5 -0
  77. data/lib/prct06/aibc.rb +62 -0
  78. data/lib/prct06/alimentos.rb +53 -0
  79. data/lib/prct06/list.rb +104 -0
  80. data/lib/prct06/receta.rb +134 -0
  81. data/lib/prct06/sort.rb +38 -0
  82. data/lib/prct06/version.rb +3 -0
  83. data/prct06.gemspec +29 -0
  84. metadata +209 -0
@@ -0,0 +1,203 @@
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
+ </script>
12
+
13
+ <script src="./js/jquery.js"></script>
14
+ <script src="./js/darkfish.js"></script>
15
+
16
+ <link href="./css/fonts.css" rel="stylesheet">
17
+ <link href="./css/rdoc.css" rel="stylesheet">
18
+
19
+
20
+
21
+ <body id="top" class="table-of-contents">
22
+ <main role="main">
23
+ <h1 class="class">Table of Contents - RDoc Documentation</h1>
24
+
25
+ <h2 id="pages">Pages</h2>
26
+ <ul>
27
+ <li class="file">
28
+ <a href="Gemfile.html">Gemfile</a>
29
+ </li>
30
+ <li class="file">
31
+ <a href="Gemfile_lock.html">Gemfile.lock</a>
32
+ </li>
33
+ <li class="file">
34
+ <a href="Guardfile.html">Guardfile</a>
35
+ </li>
36
+ <li class="file">
37
+ <a href="README_md.html">README</a>
38
+
39
+ <ul>
40
+ <li><a href="README_md.html#label-Prct06">Prct06</a>
41
+ <li><a href="README_md.html#label-Installation">Installation</a>
42
+ <li><a href="README_md.html#label-Usage">Usage</a>
43
+ <li><a href="README_md.html#label-Development">Development</a>
44
+ <li><a href="README_md.html#label-Contributing">Contributing</a>
45
+ </ul>
46
+ </li>
47
+ <li class="file">
48
+ <a href="Rakefile.html">Rakefile</a>
49
+ </li>
50
+ <li class="file">
51
+ <a href="bin/setup.html">setup</a>
52
+ </li>
53
+ <li class="file">
54
+ <a href="prct06_gemspec.html">prct06.gemspec</a>
55
+ </li>
56
+
57
+ </ul>
58
+
59
+ <h2 id="classes">Classes and Modules</h2>
60
+ <ul>
61
+ <li class="class">
62
+ <a href="Alimentos.html">Alimentos</a>
63
+ </li>
64
+ <li class="class">
65
+ <a href="AlimentosCarbohidratos.html">AlimentosCarbohidratos</a>
66
+ </li>
67
+ <li class="class">
68
+ <a href="AlimentosGrasos.html">AlimentosGrasos</a>
69
+ </li>
70
+ <li class="class">
71
+ <a href="Bebidas.html">Bebidas</a>
72
+ </li>
73
+ <li class="class">
74
+ <a href="CarnesDerivados.html">CarnesDerivados</a>
75
+ </li>
76
+ <li class="class">
77
+ <a href="Frutas.html">Frutas</a>
78
+ </li>
79
+ <li class="class">
80
+ <a href="HuevosLacteosHelados.html">HuevosLacteosHelados</a>
81
+ </li>
82
+ <li class="class">
83
+ <a href="List.html">List</a>
84
+ </li>
85
+ <li class="class">
86
+ <a href="Node.html">Node</a>
87
+ </li>
88
+ <li class="class">
89
+ <a href="Object.html">Object</a>
90
+ </li>
91
+ <li class="class">
92
+ <a href="PescadosMariscos.html">PescadosMariscos</a>
93
+ </li>
94
+ <li class="module">
95
+ <a href="Prct06.html">Prct06</a>
96
+ </li>
97
+ <li class="class">
98
+ <a href="VerdurasHortalizas.html">VerdurasHortalizas</a>
99
+ </li>
100
+ </ul>
101
+
102
+ <h2 id="methods">Methods</h2>
103
+ <ul>
104
+
105
+ <li class="method">
106
+ <a href="Alimentos.html#method-c-new">::new</a>
107
+ &mdash;
108
+ <span class="container">Alimentos</span>
109
+
110
+ <li class="method">
111
+ <a href="List.html#method-c-new">::new</a>
112
+ &mdash;
113
+ <span class="container">List</span>
114
+
115
+ <li class="method">
116
+ <a href="Alimentos.html#method-i-3C-3D-3E">#&lt;=&gt;</a>
117
+ &mdash;
118
+ <span class="container">Alimentos</span>
119
+
120
+ <li class="method">
121
+ <a href="Node.html#method-i-3C-3D-3E">#&lt;=&gt;</a>
122
+ &mdash;
123
+ <span class="container">Node</span>
124
+
125
+ <li class="method">
126
+ <a href="List.html#method-i-add">#add</a>
127
+ &mdash;
128
+ <span class="container">List</span>
129
+
130
+ <li class="method">
131
+ <a href="List.html#method-i-each">#each</a>
132
+ &mdash;
133
+ <span class="container">List</span>
134
+
135
+ <li class="method">
136
+ <a href="Alimentos.html#method-i-energy">#energy</a>
137
+ &mdash;
138
+ <span class="container">Alimentos</span>
139
+
140
+ <li class="method">
141
+ <a href="Alimentos.html#method-i-format">#format</a>
142
+ &mdash;
143
+ <span class="container">Alimentos</span>
144
+
145
+ <li class="method">
146
+ <a href="Alimentos.html#method-i-glucidos">#glucidos</a>
147
+ &mdash;
148
+ <span class="container">Alimentos</span>
149
+
150
+ <li class="method">
151
+ <a href="List.html#method-i-head">#head</a>
152
+ &mdash;
153
+ <span class="container">List</span>
154
+
155
+ <li class="method">
156
+ <a href="Alimentos.html#method-i-lipidos">#lipidos</a>
157
+ &mdash;
158
+ <span class="container">Alimentos</span>
159
+
160
+ <li class="method">
161
+ <a href="Alimentos.html#method-i-name">#name</a>
162
+ &mdash;
163
+ <span class="container">Alimentos</span>
164
+
165
+ <li class="method">
166
+ <a href="List.html#method-i-pop">#pop</a>
167
+ &mdash;
168
+ <span class="container">List</span>
169
+
170
+ <li class="method">
171
+ <a href="Alimentos.html#method-i-proteinas">#proteinas</a>
172
+ &mdash;
173
+ <span class="container">Alimentos</span>
174
+
175
+ <li class="method">
176
+ <a href="List.html#method-i-shift">#shift</a>
177
+ &mdash;
178
+ <span class="container">List</span>
179
+
180
+ <li class="method">
181
+ <a href="List.html#method-i-tail">#tail</a>
182
+ &mdash;
183
+ <span class="container">List</span>
184
+
185
+ <li class="method">
186
+ <a href="List.html#method-i-to_array">#to_array</a>
187
+ &mdash;
188
+ <span class="container">List</span>
189
+
190
+ <li class="method">
191
+ <a href="Node.html#method-i-to_s">#to_s</a>
192
+ &mdash;
193
+ <span class="container">Node</span>
194
+ </ul>
195
+ </main>
196
+
197
+
198
+ <footer id="validator-badges" role="contentinfo">
199
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
200
+ <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.1.
201
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
202
+ </footer>
203
+
@@ -0,0 +1,5 @@
1
+ require "prct06/version"
2
+
3
+ module Prct06
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,62 @@
1
+ def aibc_imperativa(g)
2
+ i = 0
3
+ r = []
4
+ while i < g.size
5
+ index = 1
6
+ s = []
7
+ while index < g[i].size
8
+ if g[i][index] < g[i][0]
9
+ s << 0.0
10
+ else
11
+ s << (((g[i][index] - g[i][0]) + (g[i][index-1] - g[i][0]))/2)*5
12
+ end
13
+ index = index + 1
14
+ end
15
+ r << s
16
+ i = i + 1
17
+ end
18
+
19
+ suma = []
20
+ j = 0
21
+ while j < g.size
22
+ k = 0
23
+ s = 0
24
+ while k < r[j].size
25
+ s = s + r[j][k]
26
+ k = k + 1
27
+ end
28
+ suma << s
29
+ j = j + 1
30
+ end
31
+ suma
32
+ end
33
+
34
+ def ig(aibc_alimento, aibc_glucosa)
35
+ ig_alimento = (((aibc_alimento[0] /aibc_glucosa[0])*100) + (((aibc_alimento[1] /aibc_glucosa[1]))*100))/2
36
+ end
37
+
38
+ #def aibc_funcional_fisttry(g)
39
+ #g.each...
40
+ # aibc=
41
+ # g=g.first()
42
+ # s = g.each_cons(2).to_a
43
+ # s= s.collect{|a| (((a[1] - g[0]) + (a[0] - g[0]))/2)*5}
44
+ # y = g.zip(s)
45
+ # z = y.collect{|v| (0.0 if v[0] < g[0]) ||v[1]}
46
+ # z = z.find_all{|x| x != nil}
47
+ # return [z.reduce(:+)]
48
+ #end
49
+
50
+
51
+ $concentracionThis = []
52
+ $concentracionGlucosa = []
53
+ def aibc_funcional
54
+ aibc = lambda {|list| list.drop(1).zip(list.first(list.count - 1)).map {|i| i[0] < list.first ? 0 : (((i[0] - list.first) + (i[1] - list.first))/2) * 5}.reduce(:+)}
55
+ igIndAll = $concentracionThis.zip($concentracionGlucosa).map{|dataPair| [aibc.call(dataPair[0]), aibc.call(dataPair[1])]}.map{|aibcPair| (aibcPair[0] / aibcPair[1]) * 100}
56
+ igIndAll.reduce(:+)/igIndAll.count
57
+ end
58
+
59
+ def measure(alimento, glucosa)
60
+ $concentracionThis << alimento
61
+ $concentracionGlucosa << glucosa
62
+ end
@@ -0,0 +1,53 @@
1
+ class Alimentos
2
+ include Comparable
3
+ def <=>(anOther)
4
+ energy <=> anOther.energy
5
+ end
6
+
7
+ def initialize(nombre, proteinas, glucidos, lipidos)
8
+ @nombre = nombre
9
+ @proteinas = proteinas
10
+ @glucidos = glucidos
11
+ @lipidos = lipidos
12
+ end
13
+ def name
14
+ @nombre
15
+ end
16
+ def proteinas
17
+ @proteinas
18
+ end
19
+ def glucidos
20
+ @glucidos
21
+ end
22
+ def lipidos
23
+ @lipidos
24
+ end
25
+ def format
26
+ "(Alimento: #{@nombre}, proteinas: #{@proteinas}, glucidos: #{@glucidos}, lipidos: #{@lipidos})"
27
+ end
28
+ def energy
29
+ @energy = (@proteinas * 4 + @glucidos * 4 + @lipidos *9).round(1)
30
+ end
31
+ def to_s
32
+ "#{@nombre}(#{@energy})"
33
+ end
34
+ end
35
+
36
+ #jerarquía de clases que permita clasificar los alimentos por grupos
37
+ class HuevosLacteosHelados < Alimentos
38
+ end
39
+ class CarnesDerivados < Alimentos
40
+ end
41
+ class PescadosMariscos < Alimentos
42
+ end
43
+ class AlimentosGrasos < Alimentos
44
+ end
45
+ class AlimentosCarbohidratos < Alimentos
46
+ end
47
+ class VerdurasHortalizas < Alimentos
48
+ end
49
+ class Frutas < Alimentos
50
+ end
51
+ class Bebidas < Alimentos
52
+ end
53
+
@@ -0,0 +1,104 @@
1
+ # create a Struct with :value, :next and :prev
2
+ Node = Struct.new(:value, :nex, :prev)
3
+
4
+ class Node
5
+ include Comparable
6
+ def <=>(anOther)
7
+ if anOther.is_a?(Node)
8
+ value <=> anOther.value
9
+ else
10
+ value <=> anOther
11
+ end
12
+ end
13
+ def to_s
14
+ to_return = "(Value: #{value})"
15
+ end
16
+ end
17
+
18
+ class List
19
+ include Enumerable
20
+ def initialize
21
+ @head = nil
22
+ @tail = nil
23
+ end
24
+
25
+ def head
26
+ @head
27
+ end
28
+ def tail
29
+ @tail
30
+ end
31
+
32
+ def add(value)
33
+ node = Node.new(value, nil, nil)
34
+ if @head == nil
35
+ @head = node
36
+ end
37
+ if @tail != nil
38
+ @tail.nex = node
39
+ node.prev = @tail
40
+ end
41
+ @tail = node
42
+ return self
43
+ end
44
+
45
+ def shift
46
+ if @head != nil
47
+ if @head.nex != nil
48
+ toReturn = @head
49
+ @head = @head.nex
50
+ @head.prev = nil
51
+ return toReturn
52
+ else
53
+ lastElement = @head
54
+ @head = nil
55
+ return lastElement
56
+ end
57
+ else
58
+ return "List is empty"
59
+ end
60
+ end
61
+
62
+ def pop
63
+ if @tail != nil
64
+ if @tail.prev != nil
65
+ toReturn = @tail
66
+ @tail = @tail.prev
67
+ @tail.nex = nil
68
+ return toReturn
69
+ else
70
+ lastElement = @tail
71
+ @tail = nil
72
+ return lastElement
73
+ end
74
+ else
75
+ return "List is empty"
76
+ end
77
+ end
78
+
79
+ def to_array
80
+ resultArray = []
81
+ current = @head
82
+ while current != nil do
83
+ resultArray << current
84
+ current = current.nex
85
+ end
86
+ return resultArray
87
+ end
88
+
89
+ def each(&block)
90
+ to_array.each(&block)
91
+ end
92
+ end
93
+
94
+ #trying things
95
+
96
+ list = List.new()
97
+ list.add(2)
98
+ list.add(6)
99
+ list.add(9)
100
+ #puts list.to_array
101
+ #list.each{|node| node.value > 2}
102
+ #node1 = Node.new(14, nil, nil)
103
+ #node2 = Node.new(3, node1, node1)
104
+ #puts node2.to_s
@@ -0,0 +1,134 @@
1
+ require "/home/usuario/LPP/prct06/lib/prct06/alimentos.rb"
2
+
3
+ class Plato
4
+ attr_accessor :name, :ingredients, :instructions
5
+
6
+ @@unityConverter = {
7
+ "piezas pequeñas" => 50,
8
+ "pieza pequeña" => 50,
9
+ "taza" => 200,
10
+ "tazas" => 200,
11
+ "cucharón" => 70,
12
+ "cucharónes" => 70,
13
+ "pieza" => 50,
14
+ "piezas" => 50,
15
+ "cucharada" => 10,
16
+ "cucharadas" => 10
17
+ }
18
+
19
+ @@tabla = [
20
+ HuevosLacteosHelados.new("Huevo frito", 14.1, 0.0, 19.5),
21
+ HuevosLacteosHelados.new("Leche vaca", 3.3, 4.8, 3.2),
22
+ HuevosLacteosHelados.new("Yogurt", 3.8, 4.9, 3.8),
23
+ HuevosLacteosHelados.new("Huevo", 3.3, 4.8, 3.2),
24
+ CarnesDerivados.new("Cerdo", 21.5, 0.0, 6.3),
25
+ CarnesDerivados.new("Ternera", 21.1, 0.0, 3.1),
26
+ CarnesDerivados.new("Pollo", 20.6, 0.0, 5.6),
27
+ PescadosMariscos.new("Bacalao", 17.7, 0.0, 0.4),
28
+ PescadosMariscos.new("Atún", 21.5, 0.0, 15.5),
29
+ PescadosMariscos.new("Salmón", 19.9, 0.0, 13.6),
30
+ AlimentosGrasos.new("Aceite de oliva", 0.0, 0.2, 99.6),
31
+ AlimentosGrasos.new("Mantequilla", 0.7, 0.0, 83.2),
32
+ AlimentosGrasos.new("Chocolate", 5.3, 47.0, 30.0),
33
+ AlimentosCarbohidratos.new("Azúcar", 0.0, 99.8, 0.0),
34
+ AlimentosCarbohidratos.new("Arroz", 6.8, 77.7, 0.6),
35
+ AlimentosCarbohidratos.new("Lentejas", 23.5, 52.0, 1.4),
36
+ AlimentosCarbohidratos.new("Papas", 2.0, 15.4, 0.1),
37
+ VerdurasHortalizas.new("Tomate", 1.0, 3.5, 0.2),
38
+ VerdurasHortalizas.new("Cebolla", 1.3, 5.8, 0.3),
39
+ VerdurasHortalizas.new("Calabaza", 1.1, 4.8, 0.1),
40
+ Frutas.new("Manzana", 0.3, 12.4, 0.4),
41
+ Frutas.new("Plátano", 1.2, 21.4, 0.2),
42
+ Frutas.new("Pera", 0.5, 12.7, 0.3)
43
+ ]
44
+
45
+ def initialize(name, &block)
46
+ @name = name
47
+ @ingredients = []
48
+ @valorEnergeticoTotal = 0.0
49
+
50
+ if block_given?
51
+ if block.arity == 1
52
+ yield self
53
+ else
54
+ instance_eval(&block)
55
+ end
56
+ end
57
+ end
58
+
59
+ def to_s
60
+ output = @name
61
+ output << "\n#{'=' * @name.size}\n"
62
+ output << "Composición nutricional:\n"
63
+ output << "\t\tglúcidos \tproteínas \tlípidos \tvalor energético\n"
64
+ output << "#{@ingredients.join("\n")}"
65
+ output << "\nValor energético total\t\t\t\t\t\t#{@valorEnergeticoTotal.round(2)}"
66
+ end
67
+
68
+ def translateAmount(amount)
69
+ if amount[:gramos] != nil
70
+ amount[:gramos]
71
+ elsif amount[:porcion] != nil
72
+ text = amount[:porcion].partition(" ")
73
+ number = text[0].to_f
74
+ amount = @@unityConverter[text[2].strip.to_s]
75
+ number * amount
76
+ else
77
+ nil
78
+ end
79
+ end
80
+
81
+ def ingredient(name, options)
82
+ ingredient = ""
83
+ ingredient << name
84
+ name.length < 8 ? ingredient << "\t" : ingredient << ""
85
+ amount = translateAmount(options)
86
+ @@tabla.each do |alimento|
87
+ if name == alimento.name
88
+ ingredient << "\t#{alimento.glucidos}\t\t#{alimento.proteinas}\t\t#{alimento.lipidos}\t\t"
89
+ energy = amount * alimento.energy / 100
90
+ ingredient << "#{energy.round(2)}"
91
+ @valorEnergeticoTotal += energy
92
+ @ingredients << ingredient
93
+ end
94
+ end
95
+ end
96
+
97
+ def vegetal(name, options = {})
98
+ ingredient(name, options)
99
+ end
100
+
101
+ def fruta(name, options = {})
102
+ ingredient(name, options)
103
+ end
104
+
105
+ def cereal(name, options = {})
106
+ ingredient(name, options)
107
+ end
108
+
109
+ def proteina(name, options = {})
110
+ ingredient(name, options)
111
+ end
112
+
113
+ def aceite(name, options = {})
114
+ ingredient(name, options)
115
+ end
116
+
117
+ end
118
+
119
+ #lentejas_arroz = Plato.new("Lentejas con arroz, salsa de tomate, huevo y plátano a la plancha") do
120
+ # vegetal "Tomate",
121
+ # :porcion => "2 piezas pequeñas"
122
+ # fruta "Plátano",
123
+ # :gramos => 20
124
+ # cereal "Arroz",
125
+ # :porcion => "1 taza"
126
+ # proteina "Lentejas",
127
+ # :porcion => "0.5 cucharón"
128
+ # proteina "Huevo",
129
+ # :porcion => "1 pieza"
130
+ # aceite "Aceite de oliva",
131
+ # :porcion => "0.5 cucharada"
132
+ #end
133
+ #
134
+ #puts lentejas_arroz