huella 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.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +2 -0
  3. data/.gitignore +11 -0
  4. data/.rspec +3 -0
  5. data/.travis.yml +7 -0
  6. data/Gemfile +4 -0
  7. data/Gemfile.lock +97 -0
  8. data/Guardfile +82 -0
  9. data/README.md +48 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/docs/Alimento.html +627 -0
  14. data/docs/Gemfile.html +98 -0
  15. data/docs/Gemfile_lock.html +179 -0
  16. data/docs/Guardfile.html +165 -0
  17. data/docs/Huella/Error.html +103 -0
  18. data/docs/Huella.html +114 -0
  19. data/docs/Lista.html +981 -0
  20. data/docs/Object.html +337 -0
  21. data/docs/PlatoAmbiental.html +436 -0
  22. data/docs/PlatoNutricional.html +517 -0
  23. data/docs/README_md.html +146 -0
  24. data/docs/Rakefile.html +100 -0
  25. data/docs/bin/setup.html +100 -0
  26. data/docs/created.rid +24 -0
  27. data/docs/css/fonts.css +167 -0
  28. data/docs/css/rdoc.css +590 -0
  29. data/docs/fonts/Lato-Light.ttf +0 -0
  30. data/docs/fonts/Lato-LightItalic.ttf +0 -0
  31. data/docs/fonts/Lato-Regular.ttf +0 -0
  32. data/docs/fonts/Lato-RegularItalic.ttf +0 -0
  33. data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
  34. data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
  35. data/docs/huella_gemspec.html +133 -0
  36. data/docs/images/add.png +0 -0
  37. data/docs/images/arrow_up.png +0 -0
  38. data/docs/images/brick.png +0 -0
  39. data/docs/images/brick_link.png +0 -0
  40. data/docs/images/bug.png +0 -0
  41. data/docs/images/bullet_black.png +0 -0
  42. data/docs/images/bullet_toggle_minus.png +0 -0
  43. data/docs/images/bullet_toggle_plus.png +0 -0
  44. data/docs/images/date.png +0 -0
  45. data/docs/images/delete.png +0 -0
  46. data/docs/images/find.png +0 -0
  47. data/docs/images/loadingAnimation.gif +0 -0
  48. data/docs/images/macFFBgHack.png +0 -0
  49. data/docs/images/package.png +0 -0
  50. data/docs/images/page_green.png +0 -0
  51. data/docs/images/page_white_text.png +0 -0
  52. data/docs/images/page_white_width.png +0 -0
  53. data/docs/images/plugin.png +0 -0
  54. data/docs/images/ruby.png +0 -0
  55. data/docs/images/tag_blue.png +0 -0
  56. data/docs/images/tag_green.png +0 -0
  57. data/docs/images/transparent.png +0 -0
  58. data/docs/images/wrench.png +0 -0
  59. data/docs/images/wrench_orange.png +0 -0
  60. data/docs/images/zoom.png +0 -0
  61. data/docs/index.html +117 -0
  62. data/docs/js/darkfish.js +161 -0
  63. data/docs/js/jquery.js +4 -0
  64. data/docs/js/navigation.js +141 -0
  65. data/docs/js/navigation.js.gz +0 -0
  66. data/docs/js/search.js +109 -0
  67. data/docs/js/search_index.js +1 -0
  68. data/docs/js/search_index.js.gz +0 -0
  69. data/docs/js/searcher.js +229 -0
  70. data/docs/js/searcher.js.gz +0 -0
  71. data/docs/table_of_contents.html +378 -0
  72. data/huella.gemspec +38 -0
  73. data/lib/huella/alimento.rb +112 -0
  74. data/lib/huella/lista.rb +275 -0
  75. data/lib/huella/menu_dsl.rb +92 -0
  76. data/lib/huella/nodo.rb +7 -0
  77. data/lib/huella/plato_ambiental.rb +100 -0
  78. data/lib/huella/plato_dsl.rb +89 -0
  79. data/lib/huella/plato_nutricional.rb +102 -0
  80. data/lib/huella/version.rb +4 -0
  81. data/lib/huella.rb +14 -0
  82. metadata +238 -0
@@ -0,0 +1,102 @@
1
+ =begin
2
+ Representa a un Plato con su nombre, formado por un conjunto de alimentos con sus
3
+ respectivas cantidades. Esta clase encapsula métodos que utilizan valores energeticos.
4
+ Cabe destacar, que el conjunto representa una abstración de una estructura enumerable
5
+ como lo puede ser un Array o la clase Lista
6
+ =end
7
+ class PlatoNutricional
8
+
9
+ include Comparable
10
+
11
+ attr_reader :nombre, :listaAlimentos, :listaCantidades
12
+
13
+ def initialize(nombre, listaAlimentos, listaCantidades)
14
+
15
+ @nombre = nombre
16
+ @listaAlimentos = listaAlimentos
17
+ @listaCantidades = listaCantidades
18
+
19
+ end
20
+
21
+ #Retorna el valor energético de un plato
22
+ def getValorEnergeticoPlato
23
+
24
+ valorEnergeticoTotal = 0
25
+
26
+ alimentoWithCantidad = @listaAlimentos.zip(@listaCantidades)
27
+
28
+ alimentosMultiplicados = alimentoWithCantidad.map do |alimento, cantidad|
29
+ alimento * cantidad
30
+ end
31
+
32
+ valorEnergeticoTotal = alimentosMultiplicados.reduce(:+).getValorEnergetico
33
+ valorEnergeticoTotal.round(2)
34
+
35
+ end
36
+
37
+ #Retorna el porcentaje que aporta las porteinas en el valor energético de un plato
38
+ def getPorcentajeProteinasPlato
39
+
40
+ proteinasTotales = 0
41
+
42
+ @listaAlimentos.each_with_index do |alimento, index|
43
+ proteinasTotales += alimento.proteinas * 4.00 * @listaCantidades.at(index)
44
+ end
45
+
46
+ ( (proteinasTotales * 100.00) / self.getValorEnergeticoPlato ).round(2)
47
+
48
+ end
49
+
50
+ #Retorna el porcentaje que aporta los carbohidratos en el valor energético de un plato
51
+ def getPorcentajeCarbohidratosPlato
52
+
53
+ carbohidratosTotales = 0
54
+
55
+ @listaAlimentos.each_with_index do |alimento, index|
56
+ carbohidratosTotales += alimento.carbohidratos * 4.00 * @listaCantidades.at(index)
57
+ end
58
+
59
+ ( (carbohidratosTotales * 100.00) / self.getValorEnergeticoPlato ).round(2)
60
+
61
+ end
62
+
63
+ #Retorna el porcentaje que aporta los lípidos en el valor energético de un plato
64
+ def getPorcentajeLipidosPlato
65
+
66
+ lipidosTotales = 0
67
+
68
+ @listaAlimentos.each_with_index do |alimento, index|
69
+ lipidosTotales += alimento.lipidos * 9.00 * @listaCantidades.at(index)
70
+ end
71
+
72
+ ( (lipidosTotales * 100.00) / self.getValorEnergeticoPlato ).round(2)
73
+
74
+ end
75
+
76
+ #Retorna el Plato formateado
77
+ def to_s
78
+
79
+ salida = []
80
+
81
+ @listaAlimentos.each_with_index do |elemento, index|
82
+ salida << "[" + elemento.nombre + ", " + @listaCantidades.at(index).to_s + "]"
83
+ end
84
+
85
+ "[" + @nombre + " [" + salida.join(" ") + "]]"
86
+ end
87
+
88
+ #Compara dos Platos según su valor energético
89
+ def <=>(other)
90
+ #-1 si left < right
91
+ # 0 si left == right
92
+ # 1 si left > right
93
+ self.getValorEnergeticoPlato <=> other.getValorEnergeticoPlato
94
+ end
95
+
96
+ #Dos Platos son iguales si todos sus atributos lo son
97
+ def ==(other)
98
+ (@nombre == other.nombre) && (@listaAlimentos == listaAlimentos) &&
99
+ (@listaCantidades == listaCantidades)
100
+ end
101
+
102
+ end
@@ -0,0 +1,4 @@
1
+ #Se crea por defecto y declara la constante VERSION de la gema
2
+ module Huella
3
+ VERSION = "0.1.0"
4
+ end
data/lib/huella.rb ADDED
@@ -0,0 +1,14 @@
1
+ require "huella/version"
2
+ require "huella/alimento"
3
+ require "huella/nodo"
4
+ require "huella/lista"
5
+ require "huella/plato_nutricional"
6
+ require "huella/plato_ambiental"
7
+ require "huella/plato_dsl"
8
+ require "huella/menu_dsl"
9
+
10
+ #Aquí se coloca el código público de la gema
11
+ module Huella
12
+ class Error < StandardError; end
13
+ # Your code goes here...
14
+ end
metadata ADDED
@@ -0,0 +1,238 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: huella
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - miguel141097
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-01-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: yard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: coveralls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Gema para calcular el impacto ambiental de una dieta
126
+ email:
127
+ - j2mc1410@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".coveralls.yml"
133
+ - ".gitignore"
134
+ - ".rspec"
135
+ - ".travis.yml"
136
+ - Gemfile
137
+ - Gemfile.lock
138
+ - Guardfile
139
+ - README.md
140
+ - Rakefile
141
+ - bin/console
142
+ - bin/setup
143
+ - docs/Alimento.html
144
+ - docs/Gemfile.html
145
+ - docs/Gemfile_lock.html
146
+ - docs/Guardfile.html
147
+ - docs/Huella.html
148
+ - docs/Huella/Error.html
149
+ - docs/Lista.html
150
+ - docs/Object.html
151
+ - docs/PlatoAmbiental.html
152
+ - docs/PlatoNutricional.html
153
+ - docs/README_md.html
154
+ - docs/Rakefile.html
155
+ - docs/bin/setup.html
156
+ - docs/created.rid
157
+ - docs/css/fonts.css
158
+ - docs/css/rdoc.css
159
+ - docs/fonts/Lato-Light.ttf
160
+ - docs/fonts/Lato-LightItalic.ttf
161
+ - docs/fonts/Lato-Regular.ttf
162
+ - docs/fonts/Lato-RegularItalic.ttf
163
+ - docs/fonts/SourceCodePro-Bold.ttf
164
+ - docs/fonts/SourceCodePro-Regular.ttf
165
+ - docs/huella_gemspec.html
166
+ - docs/images/add.png
167
+ - docs/images/arrow_up.png
168
+ - docs/images/brick.png
169
+ - docs/images/brick_link.png
170
+ - docs/images/bug.png
171
+ - docs/images/bullet_black.png
172
+ - docs/images/bullet_toggle_minus.png
173
+ - docs/images/bullet_toggle_plus.png
174
+ - docs/images/date.png
175
+ - docs/images/delete.png
176
+ - docs/images/find.png
177
+ - docs/images/loadingAnimation.gif
178
+ - docs/images/macFFBgHack.png
179
+ - docs/images/package.png
180
+ - docs/images/page_green.png
181
+ - docs/images/page_white_text.png
182
+ - docs/images/page_white_width.png
183
+ - docs/images/plugin.png
184
+ - docs/images/ruby.png
185
+ - docs/images/tag_blue.png
186
+ - docs/images/tag_green.png
187
+ - docs/images/transparent.png
188
+ - docs/images/wrench.png
189
+ - docs/images/wrench_orange.png
190
+ - docs/images/zoom.png
191
+ - docs/index.html
192
+ - docs/js/darkfish.js
193
+ - docs/js/jquery.js
194
+ - docs/js/navigation.js
195
+ - docs/js/navigation.js.gz
196
+ - docs/js/search.js
197
+ - docs/js/search_index.js
198
+ - docs/js/search_index.js.gz
199
+ - docs/js/searcher.js
200
+ - docs/js/searcher.js.gz
201
+ - docs/table_of_contents.html
202
+ - huella.gemspec
203
+ - lib/huella.rb
204
+ - lib/huella/alimento.rb
205
+ - lib/huella/lista.rb
206
+ - lib/huella/menu_dsl.rb
207
+ - lib/huella/nodo.rb
208
+ - lib/huella/plato_ambiental.rb
209
+ - lib/huella/plato_dsl.rb
210
+ - lib/huella/plato_nutricional.rb
211
+ - lib/huella/version.rb
212
+ homepage: https://github.com/ULL-ESIT-LPP-1920/tdd-miguel141097.git
213
+ licenses: []
214
+ metadata:
215
+ allowed_push_host: https://rubygems.org
216
+ homepage_uri: https://github.com/ULL-ESIT-LPP-1920/tdd-miguel141097.git
217
+ source_code_uri: https://github.com/ULL-ESIT-LPP-1920/tdd-miguel141097.git
218
+ changelog_uri: https://github.com/ULL-ESIT-LPP-1920/tdd-miguel141097.git
219
+ post_install_message:
220
+ rdoc_options: []
221
+ require_paths:
222
+ - lib
223
+ required_ruby_version: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - ">="
226
+ - !ruby/object:Gem::Version
227
+ version: '0'
228
+ required_rubygems_version: !ruby/object:Gem::Requirement
229
+ requirements:
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ version: '0'
233
+ requirements: []
234
+ rubygems_version: 3.0.3
235
+ signing_key:
236
+ specification_version: 4
237
+ summary: Practica n°6 y 7 de LPP
238
+ test_files: []