food_alu0100904406 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 (74) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +12 -0
  4. data/.travis.yml +6 -0
  5. data/Gemfile +6 -0
  6. data/Guardfile +82 -0
  7. data/README.md +40 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/docs/Alimento_.html +407 -0
  12. data/docs/Food.html +110 -0
  13. data/docs/Gemfile.html +100 -0
  14. data/docs/Gemfile_lock.html +177 -0
  15. data/docs/Grupo_alimento.html +235 -0
  16. data/docs/Guardfile.html +177 -0
  17. data/docs/Lista.html +365 -0
  18. data/docs/Object.html +118 -0
  19. data/docs/README_md.html +151 -0
  20. data/docs/Rakefile.html +98 -0
  21. data/docs/bin/setup.html +98 -0
  22. data/docs/created.rid +16 -0
  23. data/docs/css/fonts.css +167 -0
  24. data/docs/css/rdoc.css +590 -0
  25. data/docs/fonts/Lato-Light.ttf +0 -0
  26. data/docs/fonts/Lato-LightItalic.ttf +0 -0
  27. data/docs/fonts/Lato-Regular.ttf +0 -0
  28. data/docs/fonts/Lato-RegularItalic.ttf +0 -0
  29. data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
  30. data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
  31. data/docs/food_gemspec.html +130 -0
  32. data/docs/images/add.png +0 -0
  33. data/docs/images/arrow_up.png +0 -0
  34. data/docs/images/brick.png +0 -0
  35. data/docs/images/brick_link.png +0 -0
  36. data/docs/images/bug.png +0 -0
  37. data/docs/images/bullet_black.png +0 -0
  38. data/docs/images/bullet_toggle_minus.png +0 -0
  39. data/docs/images/bullet_toggle_plus.png +0 -0
  40. data/docs/images/date.png +0 -0
  41. data/docs/images/delete.png +0 -0
  42. data/docs/images/find.png +0 -0
  43. data/docs/images/loadingAnimation.gif +0 -0
  44. data/docs/images/macFFBgHack.png +0 -0
  45. data/docs/images/package.png +0 -0
  46. data/docs/images/page_green.png +0 -0
  47. data/docs/images/page_white_text.png +0 -0
  48. data/docs/images/page_white_width.png +0 -0
  49. data/docs/images/plugin.png +0 -0
  50. data/docs/images/ruby.png +0 -0
  51. data/docs/images/tag_blue.png +0 -0
  52. data/docs/images/tag_green.png +0 -0
  53. data/docs/images/transparent.png +0 -0
  54. data/docs/images/wrench.png +0 -0
  55. data/docs/images/wrench_orange.png +0 -0
  56. data/docs/images/zoom.png +0 -0
  57. data/docs/index.html +110 -0
  58. data/docs/js/darkfish.js +161 -0
  59. data/docs/js/jquery.js +4 -0
  60. data/docs/js/navigation.js +142 -0
  61. data/docs/js/navigation.js.gz +0 -0
  62. data/docs/js/search.js +109 -0
  63. data/docs/js/search_index.js +1 -0
  64. data/docs/js/search_index.js.gz +0 -0
  65. data/docs/js/searcher.js +229 -0
  66. data/docs/js/searcher.js.gz +0 -0
  67. data/docs/table_of_contents.html +150 -0
  68. data/food.gemspec +39 -0
  69. data/lib/food/food_.rb +73 -0
  70. data/lib/food/list.rb +104 -0
  71. data/lib/food/plato.rb +146 -0
  72. data/lib/food/version.rb +3 -0
  73. data/lib/food.rb +8 -0
  74. metadata +213 -0
data/lib/food/plato.rb ADDED
@@ -0,0 +1,146 @@
1
+ require "food/version"
2
+
3
+ class Plato
4
+ attr_reader :nombre, :vegetales, :proteinas, :frutas, :aceites, :cereales, :valor_energetico
5
+
6
+ @@list = Lista.new(nil,nil)
7
+ @@list.insertEnd Grupo_alimento.new("Huevo", 14.1,0.0,19.5, "Huevos, lcteos y helados"),
8
+ Grupo_alimento.new("Leche vaca", 3.3,4.8,3.2, "Huevos, lcteos y helados"),
9
+ Grupo_alimento.new("Yogurt", 3.8, 4.9, 3.8, "Huevos, lcteos y helados"),
10
+ Grupo_alimento.new("Cerdo", 21.5, 0.0, 6.3, "Carnes y derivados"),
11
+ Grupo_alimento.new("Ternera", 21.1, 0.0, 3.1, "Carnes y derivados"),
12
+ Grupo_alimento.new("Pollo",20.6, 0.0, 5.6, "Carnes y derivados"),
13
+ Grupo_alimento.new("Bacalao", 17.7, 0.0, 0.4, "Pescados y mariscos"),
14
+ Grupo_alimento.new("Atun", 21.5, 0.0, 15.5, "Pescados y mariscos"),
15
+ Grupo_alimento.new("Salmon", 19.9, 0.0, 13.6, "Pescados y mariscos"),
16
+ Grupo_alimento.new("Aceite de oliva", 0.0,99.6, 0.0, "Alimentos grasos"),
17
+ Grupo_alimento.new("Mantequilla", 0.7, 0.0, 83.2, "Alimentos grasos"),
18
+ Grupo_alimento.new("Chocolate", 5.3, 47.0, 30.0, "Alimentos grasos"),
19
+ Grupo_alimento.new("Azucar", 0.0, 0.0, 99.8, "Alimentos ricos en carbohidratos"),
20
+ Grupo_alimento.new("Arroz",6.8, 77.7, 0.6, "Alimentos ricos en carbohidratos"),
21
+ Grupo_alimento.new("Lentejas", 23.5, 52.0, 1.4, "Alimentos ricos en carbohidratos"),
22
+ Grupo_alimento.new("Papas",2.0, 15.4, 0.1, "Alimentos ricos en carbohidratos"),
23
+ Grupo_alimento.new("Tomate", 1.0, 3.5, 0.2, "Verduras y Hortalizas"),
24
+ Grupo_alimento.new("Cebolla", 1.3, 5.8, 0.3, "Verduras y Hortalizas"),
25
+ Grupo_alimento.new("Calabaza", 1.1, 4.8, 0.1, "Verduras y Hortalizas"),
26
+ Grupo_alimento.new("Manzanas", 0.3, 12.4, 0.4, "Frutas"),
27
+ Grupo_alimento.new("Plátano", 1.2, 21.4, 0.2, "Frutas"),
28
+ Grupo_alimento.new("Pera", 0.5, 12.7, 0.3, "Frutas")
29
+
30
+ @@equivalencias = { "cucharadas"=>2,"piezas pequeñas"=>5,"taza"=>5,"cucharón"=>4,"pieza"=>8,"cucharada"=>2 }
31
+
32
+ def initialize nombre, &block
33
+ @nombre = nombre
34
+ @valor_energetico = 0
35
+
36
+ @vegetales = []
37
+ @cereales = []
38
+ @frutas = []
39
+ @proteinas = []
40
+ @aceites = []
41
+
42
+ if (block != nil)
43
+ instance_eval(&block)
44
+ end
45
+ end
46
+
47
+ def get_cantidad porcion
48
+ numero = porcion.split[0].to_r
49
+
50
+ cadena = ""
51
+ porcion.split[1..cadena.length-1].each do |x|
52
+ cadena += x + " "
53
+ end
54
+ cantidad = numero * @@equivalencias[cadena.chomp ' ']
55
+ end
56
+
57
+ def vegetal n_alimento, options = {}
58
+ cantidad = 0
59
+ alimento = @@list.detect { |x| n_alimento == x.nombre }
60
+ if options[:gramos]
61
+ cantidad = options[:gramos]
62
+ elsif options[:porcion]
63
+ cantidad = get_cantidad options[:porcion]
64
+ end
65
+ @valor_energetico += cantidad*alimento.valor_energetico
66
+ @vegetales.push([alimento, (cantidad*alimento.valor_energetico).round(3)])
67
+ end
68
+
69
+ def cereal n_alimento, options = {}
70
+ cantidad = 0
71
+ alimento = @@list.detect { |x| n_alimento == x.nombre }
72
+ if options[:gramos]
73
+ cantidad = options[:gramos]
74
+ elsif options[:porcion]
75
+ cantidad = get_cantidad options[:porcion]
76
+ end
77
+ @valor_energetico += cantidad*alimento.valor_energetico
78
+ @cereales.push([alimento, (cantidad*alimento.valor_energetico).round(3)])
79
+ end
80
+
81
+ def fruta n_alimento, options = {}
82
+ cantidad = 0
83
+ alimento = @@list.detect { |x| n_alimento == x.nombre }
84
+ if options[:gramos]
85
+ cantidad = options[:gramos]
86
+ elsif options[:porcion]
87
+ cantidad = get_cantidad options[:porcion]
88
+ end
89
+ @valor_energetico += cantidad*alimento.valor_energetico
90
+ @frutas.push([alimento, (cantidad*alimento.valor_energetico).round(3)])
91
+ end
92
+
93
+ def proteina n_alimento, options = {}
94
+ cantidad = 0
95
+ alimento = @@list.detect { |x| n_alimento == x.nombre }
96
+ if options[:gramos]
97
+ cantidad = options[:gramos]
98
+ elsif options[:porcion]
99
+ cantidad = get_cantidad options[:porcion]
100
+ end
101
+ @valor_energetico += cantidad*alimento.valor_energetico
102
+ @proteinas.push([alimento, (cantidad*alimento.valor_energetico).round(3)])
103
+ end
104
+
105
+ def aceite n_alimento, options = {}
106
+ cantidad = 0
107
+ alimento = @@list.detect { |x| n_alimento == x.nombre }
108
+ if options[:gramos]
109
+ cantidad = options[:gramos]
110
+ elsif options[:porcion]
111
+ cantidad = get_cantidad options[:porcion]
112
+ end
113
+ @valor_energetico += cantidad*alimento.valor_energetico
114
+ @aceites.push([alimento, (cantidad*alimento.valor_energetico).round(3)])
115
+ end
116
+
117
+ def to_s
118
+ cadena = @nombre + "\n"
119
+ cadena += "\nComposición nutricional: \n"
120
+
121
+ for i in 0..@vegetales.length-1 do
122
+ cadena += "%-70s\t%s\n" % [@vegetales[i][0].to_s, @vegetales[i][1].to_s]
123
+ end
124
+
125
+ for i in 0..@frutas.length-1 do
126
+ cadena += "%-70s\t%s\n" % [@frutas[i][0].to_s, @frutas[i][1].to_s]
127
+ end
128
+
129
+ for i in 0..@cereales.length-1 do
130
+ cadena += "%-70s\t%s\n" % [@cereales[i][0].to_s, @cereales[i][1].to_s]
131
+ end
132
+
133
+ for i in 0..@aceites.length-1 do
134
+ cadena += "%-70s\t%s\n" % [@aceites[i][0].to_s, @aceites[i][1].to_s]
135
+ end
136
+
137
+ for i in 0..@proteinas.length-1 do
138
+ cadena += "%-70s\t%s\n" % [@proteinas[i][0].to_s, @proteinas[i][1].to_s]
139
+ end
140
+
141
+ cadena+= "Valor energético:\t" + @valor_energetico.round(3).to_s + "\n"
142
+ cadena
143
+ end
144
+ end
145
+
146
+
@@ -0,0 +1,3 @@
1
+ module Food
2
+ VERSION = "0.1.0"
3
+ end
data/lib/food.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "food/version"
2
+ require_relative "../lib/food/food_.rb"
3
+ require_relative "../lib/food/list.rb"
4
+ require_relative "../lib/food/plato.rb"
5
+
6
+ module Food
7
+ # Your code goes here...
8
+ end
metadata ADDED
@@ -0,0 +1,213 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: food_alu0100904406
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Cristian
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-12-15 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: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
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: coveralls
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
+ description:
112
+ email:
113
+ - cristianjonay@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".coveralls.yml"
119
+ - ".gitignore"
120
+ - ".travis.yml"
121
+ - Gemfile
122
+ - Guardfile
123
+ - README.md
124
+ - Rakefile
125
+ - bin/console
126
+ - bin/setup
127
+ - docs/Alimento_.html
128
+ - docs/Food.html
129
+ - docs/Gemfile.html
130
+ - docs/Gemfile_lock.html
131
+ - docs/Grupo_alimento.html
132
+ - docs/Guardfile.html
133
+ - docs/Lista.html
134
+ - docs/Object.html
135
+ - docs/README_md.html
136
+ - docs/Rakefile.html
137
+ - docs/bin/setup.html
138
+ - docs/created.rid
139
+ - docs/css/fonts.css
140
+ - docs/css/rdoc.css
141
+ - docs/fonts/Lato-Light.ttf
142
+ - docs/fonts/Lato-LightItalic.ttf
143
+ - docs/fonts/Lato-Regular.ttf
144
+ - docs/fonts/Lato-RegularItalic.ttf
145
+ - docs/fonts/SourceCodePro-Bold.ttf
146
+ - docs/fonts/SourceCodePro-Regular.ttf
147
+ - docs/food_gemspec.html
148
+ - docs/images/add.png
149
+ - docs/images/arrow_up.png
150
+ - docs/images/brick.png
151
+ - docs/images/brick_link.png
152
+ - docs/images/bug.png
153
+ - docs/images/bullet_black.png
154
+ - docs/images/bullet_toggle_minus.png
155
+ - docs/images/bullet_toggle_plus.png
156
+ - docs/images/date.png
157
+ - docs/images/delete.png
158
+ - docs/images/find.png
159
+ - docs/images/loadingAnimation.gif
160
+ - docs/images/macFFBgHack.png
161
+ - docs/images/package.png
162
+ - docs/images/page_green.png
163
+ - docs/images/page_white_text.png
164
+ - docs/images/page_white_width.png
165
+ - docs/images/plugin.png
166
+ - docs/images/ruby.png
167
+ - docs/images/tag_blue.png
168
+ - docs/images/tag_green.png
169
+ - docs/images/transparent.png
170
+ - docs/images/wrench.png
171
+ - docs/images/wrench_orange.png
172
+ - docs/images/zoom.png
173
+ - docs/index.html
174
+ - docs/js/darkfish.js
175
+ - docs/js/jquery.js
176
+ - docs/js/navigation.js
177
+ - docs/js/navigation.js.gz
178
+ - docs/js/search.js
179
+ - docs/js/search_index.js
180
+ - docs/js/search_index.js.gz
181
+ - docs/js/searcher.js
182
+ - docs/js/searcher.js.gz
183
+ - docs/table_of_contents.html
184
+ - food.gemspec
185
+ - lib/food.rb
186
+ - lib/food/food_.rb
187
+ - lib/food/list.rb
188
+ - lib/food/plato.rb
189
+ - lib/food/version.rb
190
+ homepage: https://github.com/ULL-ESIT-LPP-1718/tdd-alu0100904406
191
+ licenses: []
192
+ metadata: {}
193
+ post_install_message:
194
+ rdoc_options: []
195
+ require_paths:
196
+ - lib
197
+ required_ruby_version: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ required_rubygems_version: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
207
+ requirements: []
208
+ rubyforge_project:
209
+ rubygems_version: 2.6.8
210
+ signing_key:
211
+ specification_version: 4
212
+ summary: Gema que describe un alimento
213
+ test_files: []