menud 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,227 @@
1
+
2
+ class Menuds
3
+
4
+ attr_accessor :dia, :semana, :titulo_m, :tiempo_estimado, :desayunos, :almuerzos, :cenas, :venergetico, :venergeticot
5
+
6
+
7
+
8
+ def initialize(dia, semana, &block)
9
+
10
+ @dia=dia
11
+ @semana=semana
12
+ @tiempo_estimado= []
13
+ @titulo_m
14
+ @desayunos= []
15
+ @almuerzos= []
16
+ @cenas= []
17
+ @venergetico=nil
18
+ @venergeticot=0
19
+
20
+
21
+ if block_given?
22
+ if block.arity == 1
23
+ yield self
24
+ else
25
+ instance_eval(&block)
26
+ end
27
+ end
28
+ end
29
+
30
+
31
+
32
+ def titulo(nombre_menu)
33
+
34
+ @titulo_m=nombre_menu
35
+
36
+ end
37
+
38
+
39
+ def calc_venergetico(grasas, carbohidratos, proteinas, fibra, sal)
40
+
41
+ if fibra == nil then fibra = 0.0 end
42
+ if grasas == nil then grasas = 0.0 end
43
+ if carbohidratos == nil then carbohidratos = 0.0 end
44
+ if proteinas == nil then proteinas = 0.0 end
45
+ if sal == nil then sal = 0.0 end
46
+
47
+ @venergetico = (grasas * 9) + (carbohidratos * 4) + (proteinas * 4) + (fibra * 4) + (sal * 6)
48
+ @venergeticot += @venergetico
49
+
50
+ end
51
+
52
+
53
+
54
+ def cantidad(options = {})
55
+
56
+ tiempo_e = " #{options[:min]}" if options[:min]
57
+
58
+ tiempo_e << " #{options[:max]}" if options[:max]
59
+
60
+ @tiempo_estimado << tiempo_e
61
+
62
+
63
+ end
64
+
65
+
66
+ def desayuno(options = {})
67
+
68
+ desayunoss = "\n'#{options[:descripcion]}'" if options[:descripcion]
69
+ desayunoss << " (#{options[:porcion]})" if options[:porcion]
70
+ desayunoss << " (#{options[:gramos]})" if options[:gramos]
71
+ desayunoss << " (#{options[:grasas]})" if options[:grasas]
72
+ desayunoss << " (#{options[:carbohidratos]})" if options[:carbohidratos]
73
+ desayunoss << " (#{options[:proteinas]})" if options[:proteinas]
74
+ desayunoss << " (#{options[:fibra]})" if options[:fibra]
75
+ desayunoss << " (#{options[:sal]})" if options[:sal]
76
+
77
+ calc_venergetico(options[:grasas], options[:carbohidratos], options[:proteinas], options[:fibra], options[:sal])
78
+
79
+
80
+ desayunoss << sprintf("%5s", " #{@venergetico}")
81
+
82
+ @desayunos << desayunoss
83
+
84
+
85
+
86
+ end
87
+
88
+ def almuerzo(options = {})
89
+
90
+ almuerzoss = "\n'#{options[:descripcion]}'" if options[:descripcion]
91
+ almuerzoss << " (#{options[:porcion]})" if options[:porcion]
92
+ almuerzoss << " (#{options[:gramos]})" if options[:gramos]
93
+ almuerzoss << " (#{options[:grasas]})" if options[:grasas]
94
+ almuerzoss << " (#{options[:carbohidratos]})" if options[:carbohidratos]
95
+ almuerzoss << " (#{options[:proteinas]})" if options[:proteinas]
96
+ almuerzoss << " (#{options[:fibra]})" if options[:fibra]
97
+ almuerzoss << " (#{options[:sal]})" if options[:sal]
98
+
99
+ calc_venergetico(options[:grasas], options[:carbohidratos], options[:proteinas], options[:fibra], options[:sal])
100
+
101
+
102
+ almuerzoss << sprintf("%5s", " #{@venergetico.round(3)}")
103
+
104
+ @almuerzos << almuerzoss
105
+
106
+
107
+
108
+ end
109
+
110
+
111
+
112
+
113
+ def cena(options = {})
114
+
115
+ cenass = "\n'#{options[:descripcion]}'" if options[:descripcion]
116
+ cenass << " (#{options[:porcion]})" if options[:porcion]
117
+ cenass << " (#{options[:gramos]})" if options[:gramos]
118
+ cenass << " (#{options[:grasas]})" if options[:grasas]
119
+ cenass << " (#{options[:carbohidratos]})" if options[:carbohidratos]
120
+ cenass << " (#{options[:proteinas]})" if options[:proteinas]
121
+ cenass << " (#{options[:fibra]})" if options[:fibra]
122
+ cenass << " (#{options[:sal]})" if options[:sal]
123
+
124
+ calc_venergetico(options[:grasas], options[:carbohidratos], options[:proteinas], options[:fibra], options[:sal])
125
+
126
+
127
+ cenass << sprintf("%5s", " #{@venergetico}")
128
+
129
+ @cenas << cenass
130
+
131
+
132
+
133
+ end
134
+
135
+
136
+ def to_s
137
+
138
+ output = "\n" + @dia + " " + @semana + " " + @titulo_m + " Composición Nutricional"
139
+ output << "\n#{'=' * 60}\n"
140
+
141
+ cabecera = sprintf("%20s %10s %5s %5s %3s %3s %3s %3s\n","porcion", "gramos", "grasas", "carbohidratos", "proteinas", "fibra", "sal", "venergetico")
142
+
143
+ output << cabecera
144
+
145
+ output << "\nDesayuno"
146
+
147
+ @desayunos.each do |x|
148
+
149
+ output << "#{x}\n"
150
+ end
151
+
152
+ output << "\nAlmuerzo"
153
+
154
+ @almuerzos.each do |j|
155
+
156
+ output << "#{j}\n"
157
+
158
+ end
159
+
160
+ output << "\nCena"
161
+
162
+ @cenas.each do |k|
163
+
164
+ output << "#{k}\n" + "\n"
165
+
166
+ end
167
+
168
+
169
+ output << "\Venergeticot #{@venergeticot.round(3)}" + "\n"
170
+
171
+ output
172
+
173
+
174
+ end
175
+
176
+ def show
177
+
178
+ output = "\n" + @dia + " " + @semana + " " + @titulo_m + " Composición Nutricional"
179
+ output << "\n#{'=' * 60}\n"
180
+
181
+ cabecera = sprintf("%20s %10s %5s %5s %3s %3s %3s %3s\n","porcion", "gramos", "grasas", "carbohidratos", "proteinas", "fibra", "sal", "venergetico")
182
+
183
+ output << cabecera
184
+
185
+ output << "\nDesayuno"
186
+
187
+ @desayunos.each do |x|
188
+
189
+ output << "#{x}\n"
190
+ end
191
+
192
+ output << "\nAlmuerzo"
193
+
194
+ @almuerzos.each do |j|
195
+
196
+ output << "#{j}\n"
197
+
198
+ end
199
+
200
+ output << "\nCena"
201
+
202
+ @cenas.each do |k|
203
+
204
+ output << "#{k}\n" + "\n"
205
+
206
+ end
207
+
208
+
209
+ output << "\Venergeticot #{@venergeticot.round(3)}" + "\n"
210
+
211
+ puts output
212
+
213
+
214
+
215
+
216
+
217
+
218
+ end
219
+
220
+
221
+
222
+ end
223
+
224
+
225
+ #b = Menuds.new("Lunes", "Semana 1")
226
+
227
+ #b.show
@@ -0,0 +1,4 @@
1
+ module Menud
2
+
3
+ VERSION = "0.1.0"
4
+ end
@@ -0,0 +1,45 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "menud/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "menud"
8
+ spec.version = Menud::VERSION
9
+ spec.authors = ["alu0100761948"]
10
+ spec.email = ["alu0100761948@ull.edu.es"]
11
+
12
+ spec.summary = %q{Práctica de laboratorio}
13
+ spec.description = %q{Se realizaran pruebas con Spec.}
14
+ spec.homepage = "https://github.com/ULL-ESIT-LPP-1819/tdd-AlejandrDiaz"
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
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = "https://github.com/ULL-ESIT-LPP-1819/tdd-AlejandrDiaz"
24
+ spec.metadata["changelog_uri"] = "https://github.com/ULL-ESIT-LPP-1819/tdd-AlejandrDiaz"
25
+ else
26
+ raise "RubyGems 2.0 or newer is required to protect against " \
27
+ "public gem pushes."
28
+ end
29
+
30
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
31
+ f.match(%r{^(test|spec|features)/})
32
+ end
33
+ spec.bindir = "exe"
34
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
+ spec.require_paths = ["lib"]
36
+
37
+ spec.add_development_dependency "bundler", "~> 1.15"
38
+ spec.add_development_dependency "rake", "~> 10.0"
39
+ spec.add_development_dependency "rspec", "~> 3.0"
40
+ spec.add_development_dependency "guard"
41
+ spec.add_development_dependency "guard-rspec"
42
+ spec.add_development_dependency "guard-bundler"
43
+ spec.add_development_dependency "coveralls"
44
+
45
+ end
metadata ADDED
@@ -0,0 +1,180 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: menud
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - alu0100761948
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-01-10 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: Se realizaran pruebas con Spec.
112
+ email:
113
+ - alu0100761948@ull.edu.es
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/_guard-core
126
+ - bin/bundle
127
+ - bin/coderay
128
+ - bin/coveralls
129
+ - bin/guard
130
+ - bin/htmldiff
131
+ - bin/ldiff
132
+ - bin/listen
133
+ - bin/pry
134
+ - bin/rake
135
+ - bin/rdoc
136
+ - bin/ri
137
+ - bin/rspec
138
+ - bin/term_cdiff
139
+ - bin/term_colortab
140
+ - bin/term_decolor
141
+ - bin/term_display
142
+ - bin/term_mandel
143
+ - bin/term_snow
144
+ - bin/thor
145
+ - lib/menud.rb
146
+ - lib/menud/array.rb
147
+ - lib/menud/lista.rb
148
+ - lib/menud/menud.rb
149
+ - lib/menud/menuds.rb
150
+ - lib/menud/version.rb
151
+ - menud.gemspec
152
+ homepage: https://github.com/ULL-ESIT-LPP-1819/tdd-AlejandrDiaz
153
+ licenses:
154
+ - MIT
155
+ metadata:
156
+ allowed_push_host: https://rubygems.org
157
+ homepage_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-AlejandrDiaz
158
+ source_code_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-AlejandrDiaz
159
+ changelog_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-AlejandrDiaz
160
+ post_install_message:
161
+ rdoc_options: []
162
+ require_paths:
163
+ - lib
164
+ required_ruby_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ requirements: []
175
+ rubyforge_project:
176
+ rubygems_version: 2.6.11
177
+ signing_key:
178
+ specification_version: 4
179
+ summary: Práctica de laboratorio
180
+ test_files: []