prct06_alu0100948097 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Guardfile +82 -0
- data/LICENSE.txt +21 -0
- data/README.md +3 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/Alimentos.html +1033 -0
- data/docs/Array.html +345 -0
- data/docs/G_alimentos.html +476 -0
- data/docs/List.html +1196 -0
- data/docs/Node.html +421 -0
- data/docs/Prct06.html +117 -0
- data/docs/_index.html +166 -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 +499 -0
- data/docs/file.README.html +74 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +74 -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 +194 -0
- data/lib/.DS_Store +0 -0
- data/lib/prct06.rb +11 -0
- data/lib/prct06/alimentos.rb +91 -0
- data/lib/prct06/array.rb +47 -0
- data/lib/prct06/lista.rb +141 -0
- data/lib/prct06/nodo.rb +14 -0
- data/lib/prct06/receta.rb +145 -0
- data/lib/prct06/version.rb +3 -0
- data/prct06.gemspec +41 -0
- metadata +198 -0
data/lib/prct06/nodo.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Esta estructura es la definida para los nodos que formaran la lista doblemente enlazada
|
3
|
+
# Su desarrollo ha sido dirigido por pruebas (TDD).
|
4
|
+
#
|
5
|
+
# Author:: Sergio Ferrera de Diego (mailto:sergioferrera1296@gmail.com)
|
6
|
+
# Copyright:: Cretive Commons
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
|
9
|
+
Node = Struct.new(:value, :next, :prev)
|
10
|
+
|
11
|
+
# Método para definir la forma en la que comparar nodos
|
12
|
+
def <=>(other)
|
13
|
+
value <=> other.value
|
14
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
class Recipe
|
2
|
+
|
3
|
+
attr_reader :name, :alimentos, :valor_ener_total
|
4
|
+
|
5
|
+
def initialize(name,&block)
|
6
|
+
@@tabla_alimentos=[
|
7
|
+
Alimentos.new("Huevo frito", 14.1, 0.0, 19.5),
|
8
|
+
Alimentos.new("Leche vaca", 3.3, 4.8, 3.2),
|
9
|
+
Alimentos.new("Yogurt", 3.8, 4.9, 3.8),
|
10
|
+
Alimentos.new("Cerdo", 21.5, 0.0, 6.3),
|
11
|
+
Alimentos.new("Ternera", 21.1, 0.0, 3.1),
|
12
|
+
Alimentos.new("Pollo", 20.6, 0.0, 5.6),
|
13
|
+
Alimentos.new("Bacalao", 17.7, 0.0, 0.4),
|
14
|
+
Alimentos.new("Atun", 21.5, 0.0, 15.5),
|
15
|
+
Alimentos.new("Salmon", 19.9, 0.0, 13.6),
|
16
|
+
Alimentos.new("Aceite de oliva", 0.0, 0.2, 99.6),
|
17
|
+
Alimentos.new("Aceite de girasol",0.0,0.9,83.1),
|
18
|
+
Alimentos.new("Mantequilla", 0.7, 0.0, 83.2),
|
19
|
+
Alimentos.new("Chocolate", 5.3, 47.0, 30.0),
|
20
|
+
Alimentos.new("Azucar", 0.0, 99.8, 0.0),
|
21
|
+
Alimentos.new("Arroz", 6.8, 77.7, 0.6),
|
22
|
+
Alimentos.new("Lentejas", 23.5, 52.0, 1.4),
|
23
|
+
Alimentos.new("Papas", 2.0, 15.4, 0.1),
|
24
|
+
Alimentos.new("Tomate", 1.0, 3.5, 0.2),
|
25
|
+
Alimentos.new("Cebolla", 1.3, 5.8, 0.3),
|
26
|
+
Alimentos.new("Calabaza", 1.1, 4.8, 0.1),
|
27
|
+
Alimentos.new("Manzana", 0.3, 12.4, 0.4),
|
28
|
+
Alimentos.new("Platano", 1.2, 21.4, 0.2),
|
29
|
+
Alimentos.new("Pera", 0.5, 12.7, 0.3)
|
30
|
+
]
|
31
|
+
@@porciones={"cucharada"=>15,"cucharon"=>40,"taza"=>100,"pieza"=>150}
|
32
|
+
@name = name
|
33
|
+
@alimentos=[]
|
34
|
+
@valor_ener_total=0;
|
35
|
+
|
36
|
+
if block_given? #Comprueba si el bloque existe
|
37
|
+
if block.arity == 1 #Devuelve la cantidad de argumentos del bloque
|
38
|
+
yield self
|
39
|
+
else
|
40
|
+
instance_eval(&block)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def vegetal(nombre_alimento, options = {})
|
46
|
+
|
47
|
+
food=@@tabla_alimentos.find{|x| x.alimento==nombre_alimento}
|
48
|
+
ingredient = food.alimento
|
49
|
+
|
50
|
+
sz=23-food.alimento.size
|
51
|
+
ingredient << "#{" "*sz}#{food.glucidos}#{" "*9}#{food.proteinas}#{" "*8}#{food.grasas}#{" "*8}#{food.valor_ener.round(2)} "
|
52
|
+
|
53
|
+
if options[:porcion]
|
54
|
+
almacen=options[:porcion].split
|
55
|
+
ingredient << "#{" "*11}#{almacen[0].to_f*@@porciones[almacen[1]]} gr"
|
56
|
+
end
|
57
|
+
|
58
|
+
@valor_ener_total+=food.valor_ener
|
59
|
+
@alimentos << ingredient
|
60
|
+
ingredient
|
61
|
+
end
|
62
|
+
|
63
|
+
def fruta(nombre_alimento, options = {})
|
64
|
+
|
65
|
+
food=@@tabla_alimentos.find{|x| x.alimento==nombre_alimento}
|
66
|
+
ingredient=food.alimento
|
67
|
+
|
68
|
+
sz=23-food.alimento.size
|
69
|
+
ingredient << "#{" "*sz}#{food.glucidos}#{" "*9}#{food.proteinas}#{" "*8}#{food.grasas}#{" "*8}#{food.valor_ener.round(2)} "
|
70
|
+
|
71
|
+
if options[:porcion]
|
72
|
+
almacen=options[:porcion].split
|
73
|
+
ingredient << "#{" "*11}#{almacen[0].to_f*@@porciones[almacen[1]]} gr"
|
74
|
+
end
|
75
|
+
|
76
|
+
@valor_ener_total+=food.valor_ener
|
77
|
+
@alimentos << ingredient
|
78
|
+
ingredient
|
79
|
+
end
|
80
|
+
|
81
|
+
def cereal(nombre_alimento, options = {})
|
82
|
+
|
83
|
+
food=@@tabla_alimentos.find{|x| x.alimento==nombre_alimento}
|
84
|
+
ingredient = food.alimento
|
85
|
+
|
86
|
+
sz=23-food.alimento.size
|
87
|
+
ingredient << "#{" "*sz}#{food.glucidos}#{" "*9}#{food.proteinas}#{" "*8}#{food.grasas}#{" "*8}#{food.valor_ener.round(2)} "
|
88
|
+
|
89
|
+
if options[:porcion]
|
90
|
+
almacen=options[:porcion].split
|
91
|
+
ingredient << "#{" "*11}#{almacen[0].to_f*@@porciones[almacen[1]]} gr"
|
92
|
+
end
|
93
|
+
|
94
|
+
@valor_ener_total+=food.valor_ener
|
95
|
+
@alimentos << ingredient
|
96
|
+
ingredient
|
97
|
+
end
|
98
|
+
|
99
|
+
def proteina(nombre_alimento, options = {})
|
100
|
+
|
101
|
+
food=@@tabla_alimentos.find{|x| x.alimento==nombre_alimento}
|
102
|
+
ingredient = food.alimento
|
103
|
+
|
104
|
+
sz=23-food.alimento.size
|
105
|
+
ingredient << "#{" "*sz}#{food.glucidos}#{" "*9}#{food.proteinas}#{" "*8}#{food.grasas}#{" "*8}#{food.valor_ener.round(2)} "
|
106
|
+
|
107
|
+
if options[:porcion]
|
108
|
+
almacen=options[:porcion].split
|
109
|
+
ingredient << "#{" "*11}#{almacen[0].to_f*@@porciones[almacen[1]]} gr"
|
110
|
+
end
|
111
|
+
|
112
|
+
@valor_ener_total+=food.valor_ener
|
113
|
+
@alimentos << ingredient
|
114
|
+
ingredient
|
115
|
+
end
|
116
|
+
|
117
|
+
def aceite(nombre_alimento, options = {})
|
118
|
+
|
119
|
+
food=@@tabla_alimentos.find{|x| x.alimento==nombre_alimento}
|
120
|
+
ingredient = food.alimento
|
121
|
+
|
122
|
+
sz=23-food.alimento.size
|
123
|
+
ingredient << "#{" "*sz}#{food.glucidos}#{" "*9}#{food.proteinas}#{" "*8}#{food.grasas}#{" "*8}#{food.valor_ener.round(2)} "
|
124
|
+
|
125
|
+
if options[:porcion]
|
126
|
+
almacen=options[:porcion].split
|
127
|
+
ingredient << "#{" "*11}#{almacen[0].to_f*@@porciones[almacen[1]]} gr"
|
128
|
+
end
|
129
|
+
|
130
|
+
@valor_ener_total+=food.valor_ener
|
131
|
+
@alimentos << ingredient
|
132
|
+
ingredient
|
133
|
+
end
|
134
|
+
|
135
|
+
def to_s
|
136
|
+
output = @name
|
137
|
+
output << "\n#{'=' * @name.size}\n"
|
138
|
+
output << "Composición nutricional:\n"
|
139
|
+
output << " Glúcidos Proteínas Lípidos Valor energético Cantidad\n"
|
140
|
+
output << "#{@alimentos.join("\n")}\n\n"
|
141
|
+
output << "valor energético total ==> #{@valor_ener_total}\n\n"
|
142
|
+
output
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
data/prct06.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "prct06/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "prct06_alu0100948097"
|
8
|
+
spec.version = Prct06::VERSION
|
9
|
+
spec.authors = ["Sergio Ferrera de Diego"]
|
10
|
+
spec.email = ["alu0100948097@ull.edu.es"]
|
11
|
+
|
12
|
+
spec.summary = "Practica de laboratorio #6 TDD"
|
13
|
+
spec.description = "Practica de laboratorio #6 TDD"
|
14
|
+
spec.homepage = "https://github.com/ULL-ESIT-LPP-1718/tdd-alu0100948097.git"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
spec.add_development_dependency "guard"
|
37
|
+
spec.add_development_dependency "guard-rspec"
|
38
|
+
spec.add_development_dependency "guard-bundler"
|
39
|
+
spec.add_development_dependency "yard"
|
40
|
+
spec.add_development_dependency "yard-rspec"
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: prct06_alu0100948097
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sergio Ferrera de Diego
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-13 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: 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: yard-rspec
|
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: 'Practica de laboratorio #6 TDD'
|
126
|
+
email:
|
127
|
+
- alu0100948097@ull.edu.es
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".DS_Store"
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".travis.yml"
|
136
|
+
- CODE_OF_CONDUCT.md
|
137
|
+
- Gemfile
|
138
|
+
- Guardfile
|
139
|
+
- LICENSE.txt
|
140
|
+
- README.md
|
141
|
+
- Rakefile
|
142
|
+
- bin/console
|
143
|
+
- bin/setup
|
144
|
+
- docs/Alimentos.html
|
145
|
+
- docs/Array.html
|
146
|
+
- docs/G_alimentos.html
|
147
|
+
- docs/List.html
|
148
|
+
- docs/Node.html
|
149
|
+
- docs/Prct06.html
|
150
|
+
- docs/_index.html
|
151
|
+
- docs/class_list.html
|
152
|
+
- docs/css/common.css
|
153
|
+
- docs/css/full_list.css
|
154
|
+
- docs/css/style.css
|
155
|
+
- docs/file.README.html
|
156
|
+
- docs/file_list.html
|
157
|
+
- docs/frames.html
|
158
|
+
- docs/index.html
|
159
|
+
- docs/js/app.js
|
160
|
+
- docs/js/full_list.js
|
161
|
+
- docs/js/jquery.js
|
162
|
+
- docs/method_list.html
|
163
|
+
- docs/top-level-namespace.html
|
164
|
+
- lib/.DS_Store
|
165
|
+
- lib/prct06.rb
|
166
|
+
- lib/prct06/alimentos.rb
|
167
|
+
- lib/prct06/array.rb
|
168
|
+
- lib/prct06/lista.rb
|
169
|
+
- lib/prct06/nodo.rb
|
170
|
+
- lib/prct06/receta.rb
|
171
|
+
- lib/prct06/version.rb
|
172
|
+
- prct06.gemspec
|
173
|
+
homepage: https://github.com/ULL-ESIT-LPP-1718/tdd-alu0100948097.git
|
174
|
+
licenses:
|
175
|
+
- MIT
|
176
|
+
metadata:
|
177
|
+
allowed_push_host: https://rubygems.org
|
178
|
+
post_install_message:
|
179
|
+
rdoc_options: []
|
180
|
+
require_paths:
|
181
|
+
- lib
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
requirements: []
|
193
|
+
rubyforge_project:
|
194
|
+
rubygems_version: 2.6.13
|
195
|
+
signing_key:
|
196
|
+
specification_version: 4
|
197
|
+
summary: 'Practica de laboratorio #6 TDD'
|
198
|
+
test_files: []
|