practica6germanAT 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 +2 -0
- data/.gitignore +10 -0
- data/.rspec +3 -0
- data/.travis.yml +9 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +95 -0
- data/Guardfile +85 -0
- data/README.md +19 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/doc/Comida.html +1030 -0
- data/doc/List.html +1346 -0
- data/doc/List/Node.html +409 -0
- data/doc/MejorPlato.html +1007 -0
- data/doc/Menu.html +400 -0
- data/doc/Plato.html +1125 -0
- data/doc/Practica6.html +144 -0
- data/doc/Practica6/Error.html +124 -0
- data/doc/_index.html +186 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +496 -0
- data/doc/file.README.html +97 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +97 -0
- data/doc/js/app.js +303 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +443 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/practica6.rb +14 -0
- data/lib/practica6/comida.rb +59 -0
- data/lib/practica6/lista.rb +173 -0
- data/lib/practica6/mejorplatos.rb +122 -0
- data/lib/practica6/menu.rb +48 -0
- data/lib/practica6/platos.rb +136 -0
- data/lib/practica6/version.rb +7 -0
- data/practica6.gemspec +36 -0
- metadata +167 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @autor Germán Alfonso Teixidó
|
|
2
|
+
class Menu
|
|
3
|
+
# Los atributos son de lectura y escritura.
|
|
4
|
+
attr_accessor :platosmenu, :descripcion, :preciosmenu, :preciofinal
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
# Constructor.
|
|
8
|
+
#
|
|
9
|
+
# @param [List] platosmenu Lista de platos del menú.
|
|
10
|
+
#
|
|
11
|
+
def initialize(aux, &block)
|
|
12
|
+
|
|
13
|
+
@platosmenu= []
|
|
14
|
+
@preciosmenu= []
|
|
15
|
+
|
|
16
|
+
if block_given?
|
|
17
|
+
if block.arity == 1
|
|
18
|
+
yield self
|
|
19
|
+
else
|
|
20
|
+
instance_eval(&block)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def descripcion (d)
|
|
26
|
+
@descripcion= d
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def componente (c= {})
|
|
30
|
+
@platosmenu<< c[:descripcion]
|
|
31
|
+
@preciosmenu<< c[:precio]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def precio(pf)
|
|
35
|
+
@preciofinal= pf
|
|
36
|
+
end
|
|
37
|
+
#
|
|
38
|
+
# Impacto ambiental del menú.
|
|
39
|
+
#
|
|
40
|
+
# @return [Double] Impacto ambiental del menú.
|
|
41
|
+
def impacto
|
|
42
|
+
aux= 0.0.to_d
|
|
43
|
+
@platosmenu.each do |plato|
|
|
44
|
+
aux+= (plato[0].GEI* plato[1])
|
|
45
|
+
end
|
|
46
|
+
return aux
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# @autor Germán Alfonso Teixidó
|
|
2
|
+
class Plato
|
|
3
|
+
|
|
4
|
+
# La clase es comparable.
|
|
5
|
+
include Comparable
|
|
6
|
+
|
|
7
|
+
# Los atributos son de lectura y escritura.
|
|
8
|
+
attr_accessor :nombrePlato, :conjuntoAlimentos, :conjuntoCantidades
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
# Constructor
|
|
12
|
+
#
|
|
13
|
+
# @param [String] nombrePlato Nombre del plato.
|
|
14
|
+
# @param [List] conjuntoAlimentos Lista de alimentos que forman el plato.
|
|
15
|
+
# @param [List] conjuntoCantidades Lista de cantidades de cada alimento que forma el plato.
|
|
16
|
+
#
|
|
17
|
+
def initialize(aux, &block)
|
|
18
|
+
#@nombrePlato= nombrePlato
|
|
19
|
+
|
|
20
|
+
@conjuntoAlimentos= []
|
|
21
|
+
@conjuntoCantidades= []
|
|
22
|
+
|
|
23
|
+
if block_given?
|
|
24
|
+
if block.arity == 1
|
|
25
|
+
yield self
|
|
26
|
+
else
|
|
27
|
+
instance_eval(&block)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def nombre (nombre)
|
|
34
|
+
@nombrePlato= nombre
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def alimento (a= {})
|
|
38
|
+
@conjuntoAlimentos<< a[:descripcion]
|
|
39
|
+
@conjuntoCantidades<< a[:gramos]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
#
|
|
43
|
+
# Funcion auxiliar de #porProteinas, #porLipidos y #porCarbohidratos.
|
|
44
|
+
#
|
|
45
|
+
# @return [Double] Sumatorio de glucidos, lipidos y Proteinas.
|
|
46
|
+
#
|
|
47
|
+
def conjuntoPorcentaje
|
|
48
|
+
aux= 0.0.to_d
|
|
49
|
+
conjuntoAlimentos.size.times do |i|
|
|
50
|
+
aux+= (conjuntoAlimentos[i].proteinas.to_d)* (conjuntoCantidades[i].to_d/1000.0)
|
|
51
|
+
aux+= (conjuntoAlimentos[i].carbohidratos.to_d)* (conjuntoCantidades[i].to_d/1000.0)
|
|
52
|
+
aux+= (conjuntoAlimentos[i].lipidos.to_d)* (conjuntoCantidades[i].to_d/1000.0)
|
|
53
|
+
end
|
|
54
|
+
return aux
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
#
|
|
58
|
+
# % de proteinas del plato respecto a otros componentes.
|
|
59
|
+
#
|
|
60
|
+
# @return [Double] % de proteinas del plato.
|
|
61
|
+
#
|
|
62
|
+
def porProteinas
|
|
63
|
+
auxProteinas= 0.0.to_d
|
|
64
|
+
conjuntoAlimentos.size.times do |i|
|
|
65
|
+
auxProteinas+= (conjuntoAlimentos[i].proteinas.to_d)* (conjuntoCantidades[i].to_d/1000.0)
|
|
66
|
+
end
|
|
67
|
+
return ((auxProteinas/ conjuntoPorcentaje)* 100)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
#
|
|
71
|
+
# % de lipidos del plato respecto a otros componentes.
|
|
72
|
+
#
|
|
73
|
+
# @return [Double] % de lipidos del plato.
|
|
74
|
+
#
|
|
75
|
+
def porLipidos
|
|
76
|
+
auxLipidos= 0.0.to_d
|
|
77
|
+
conjuntoAlimentos.size.times do |i|
|
|
78
|
+
auxLipidos+= (conjuntoAlimentos[i].lipidos.to_d)* (conjuntoCantidades[i].to_d/1000.0)
|
|
79
|
+
end
|
|
80
|
+
return ((auxLipidos/ conjuntoPorcentaje)* 100)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
#
|
|
84
|
+
# % de carbohidratos del plato respecto a otros componentes.
|
|
85
|
+
#
|
|
86
|
+
# @return [Double] % de carbohidratos del plato.
|
|
87
|
+
#
|
|
88
|
+
def porCarbohidratos
|
|
89
|
+
auxCarbohidratos= 0.0.to_d
|
|
90
|
+
conjuntoAlimentos.size.times do |i|
|
|
91
|
+
auxCarbohidratos+= (conjuntoAlimentos[i].carbohidratos.to_d)* (conjuntoCantidades[i].to_d/1000.0)
|
|
92
|
+
end
|
|
93
|
+
return ((auxCarbohidratos/ conjuntoPorcentaje)* 100)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
#
|
|
97
|
+
# Calor calórico del plato.
|
|
98
|
+
#
|
|
99
|
+
# @return [Double] Valor calórico del plato.
|
|
100
|
+
#
|
|
101
|
+
def valorCaloricoTotal
|
|
102
|
+
auxVCT= 0.0.to_d
|
|
103
|
+
conjuntoAlimentos.size.times do |i|
|
|
104
|
+
auxVCT+= (conjuntoAlimentos[i].kilocalorias.to_d)* (conjuntoCantidades[i].to_d/1000.0)
|
|
105
|
+
end
|
|
106
|
+
return auxVCT
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
#
|
|
110
|
+
# Foramte el plato a una cadena de texto legible.
|
|
111
|
+
#
|
|
112
|
+
# @return [String] Cadena de texto resumen del plato.
|
|
113
|
+
#
|
|
114
|
+
def to_s
|
|
115
|
+
string= "#{@nombrePlato}:\n"
|
|
116
|
+
conjuntoAlimentos.size.times do |i|
|
|
117
|
+
string+= "#{conjuntoAlimentos[i].nombre}, #{conjuntoCantidades[i]};\n"
|
|
118
|
+
end
|
|
119
|
+
return string
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
#
|
|
123
|
+
# Sobreescritura de la funcion <=> de la clase Comparable para comparar dos elementos
|
|
124
|
+
#
|
|
125
|
+
# @param [Comida] another Plato con el que se pretende comparar este Plato (el plato con mayor #porProteinas será mayor).
|
|
126
|
+
#
|
|
127
|
+
def <=>(another)
|
|
128
|
+
if another.class.ancestors.include?Plato
|
|
129
|
+
aux1= porProteinas
|
|
130
|
+
aux2= another.porProteinas
|
|
131
|
+
aux1 <=> aux2
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
end
|
data/practica6.gemspec
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require "practica6/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "practica6germanAT"
|
|
7
|
+
spec.version = Practica6::VERSION
|
|
8
|
+
spec.authors = ["Germán Alfonso Teixidó"]
|
|
9
|
+
spec.email = ["alu0100961768@ull.edu.es"]
|
|
10
|
+
|
|
11
|
+
spec.summary = %q{Practica 6}
|
|
12
|
+
spec.description = %q{Practica 6: TDD}
|
|
13
|
+
spec.homepage = "https://rubygems.org/gems/practica6"
|
|
14
|
+
|
|
15
|
+
#spec.metadata["allowed_push_host"] = "https://github.com/ULL-ESIT-LPP-1920/tdd-alu0100961768"
|
|
16
|
+
|
|
17
|
+
#spec.metadata["homepage_uri"] = spec.homepage
|
|
18
|
+
#spec.metadata["source_code_uri"] = "https://github.com/ULL-ESIT-LPP-1920/tdd-alu0100961768"
|
|
19
|
+
#spec.metadata["changelog_uri"] = "https://github.com/ULL-ESIT-LPP-1920/tdd-alu0100961768"
|
|
20
|
+
|
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
25
|
+
end
|
|
26
|
+
spec.bindir = "exe"
|
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
+
spec.require_paths = ["lib"]
|
|
29
|
+
|
|
30
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
33
|
+
spec.add_development_dependency "guard"
|
|
34
|
+
spec.add_development_dependency "guard-rspec"
|
|
35
|
+
spec.add_development_dependency "guard-bundler"
|
|
36
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: practica6germanAT
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Germán Alfonso Teixidó
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-01-09 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
|
+
description: 'Practica 6: TDD'
|
|
98
|
+
email:
|
|
99
|
+
- alu0100961768@ull.edu.es
|
|
100
|
+
executables: []
|
|
101
|
+
extensions: []
|
|
102
|
+
extra_rdoc_files: []
|
|
103
|
+
files:
|
|
104
|
+
- ".coveralls.yml"
|
|
105
|
+
- ".gitignore"
|
|
106
|
+
- ".rspec"
|
|
107
|
+
- ".travis.yml"
|
|
108
|
+
- Gemfile
|
|
109
|
+
- Gemfile.lock
|
|
110
|
+
- Guardfile
|
|
111
|
+
- README.md
|
|
112
|
+
- Rakefile
|
|
113
|
+
- bin/console
|
|
114
|
+
- bin/setup
|
|
115
|
+
- doc/Comida.html
|
|
116
|
+
- doc/List.html
|
|
117
|
+
- doc/List/Node.html
|
|
118
|
+
- doc/MejorPlato.html
|
|
119
|
+
- doc/Menu.html
|
|
120
|
+
- doc/Plato.html
|
|
121
|
+
- doc/Practica6.html
|
|
122
|
+
- doc/Practica6/Error.html
|
|
123
|
+
- doc/_index.html
|
|
124
|
+
- doc/class_list.html
|
|
125
|
+
- doc/css/common.css
|
|
126
|
+
- doc/css/full_list.css
|
|
127
|
+
- doc/css/style.css
|
|
128
|
+
- doc/file.README.html
|
|
129
|
+
- doc/file_list.html
|
|
130
|
+
- doc/frames.html
|
|
131
|
+
- doc/index.html
|
|
132
|
+
- doc/js/app.js
|
|
133
|
+
- doc/js/full_list.js
|
|
134
|
+
- doc/js/jquery.js
|
|
135
|
+
- doc/method_list.html
|
|
136
|
+
- doc/top-level-namespace.html
|
|
137
|
+
- lib/practica6.rb
|
|
138
|
+
- lib/practica6/comida.rb
|
|
139
|
+
- lib/practica6/lista.rb
|
|
140
|
+
- lib/practica6/mejorplatos.rb
|
|
141
|
+
- lib/practica6/menu.rb
|
|
142
|
+
- lib/practica6/platos.rb
|
|
143
|
+
- lib/practica6/version.rb
|
|
144
|
+
- practica6.gemspec
|
|
145
|
+
homepage: https://rubygems.org/gems/practica6
|
|
146
|
+
licenses: []
|
|
147
|
+
metadata: {}
|
|
148
|
+
post_install_message:
|
|
149
|
+
rdoc_options: []
|
|
150
|
+
require_paths:
|
|
151
|
+
- lib
|
|
152
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
153
|
+
requirements:
|
|
154
|
+
- - ">="
|
|
155
|
+
- !ruby/object:Gem::Version
|
|
156
|
+
version: '0'
|
|
157
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
|
+
requirements:
|
|
159
|
+
- - ">="
|
|
160
|
+
- !ruby/object:Gem::Version
|
|
161
|
+
version: '0'
|
|
162
|
+
requirements: []
|
|
163
|
+
rubygems_version: 3.0.3
|
|
164
|
+
signing_key:
|
|
165
|
+
specification_version: 4
|
|
166
|
+
summary: Practica 6
|
|
167
|
+
test_files: []
|