menu_Alexandra 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.
@@ -0,0 +1,305 @@
1
+
2
+ #
3
+ #Clase que representa a una persona con sus atributos
4
+ #
5
+ # @author [Alexandra]
6
+ #
7
+ module Nutri
8
+
9
+ class Persona
10
+ #getters y setters
11
+ attr_accessor :nombre, :apellido, :edad, :sexo
12
+
13
+ include Comparable
14
+
15
+ #
16
+ # Initialize
17
+ # @param nombre [char] [name]
18
+ # @param apellido [char] [surname]
19
+ # @param edad [int] [age]
20
+ # @param sexo [inr] [sex: 0= hombre, 1=mujer]
21
+ #
22
+ # @return [nil] [nothing]
23
+ def initialize(nombre, apellido, edad, sexo)
24
+ @nombre, @apellido, @edad, @sexo = nombre, apellido, edad, sexo
25
+ end
26
+
27
+ #
28
+ # [name to string]
29
+ #
30
+ # @return [char] [name as string]
31
+ def nombre_to_s
32
+ "Nombre: #{@nombre}\n"
33
+ end
34
+
35
+ #
36
+ # [surname to string]
37
+ #
38
+ # @return [char] [surname as string]
39
+ def apellido_to_s
40
+ "Apellido: #{@apellido}\n"
41
+ end
42
+
43
+ #
44
+ # [age to string]
45
+ #
46
+ # @return [char] [age as string]
47
+ def edad_to_s
48
+ "Edad: #{@edad}\n"
49
+ end
50
+
51
+ #
52
+ # [sex to string]
53
+ #
54
+ # @return [char] [sex as string]
55
+ def sexo_to_s
56
+ "Sexo: #{@sexo}\n"
57
+ end
58
+
59
+ #
60
+ # Compara los objetos sobre su edad
61
+ # @param other [object] [Person object]
62
+ #
63
+ # @return [bool] [true or false]
64
+ def <=>(other)
65
+ if other.is_a? Persona
66
+ @edad <=> other.edad
67
+ else
68
+ false
69
+ end
70
+ end
71
+
72
+ #
73
+ # Devuelve el string representado por el objeto como un char
74
+ #
75
+ # @return [char] [name and surname as string]
76
+ def formato_to_s
77
+ puts "Nombre: #{@nombre}, Apellido: #{@apellido}, Edad: #{@edad}, Sexo: #{@sexo}"
78
+ end
79
+
80
+
81
+ end
82
+
83
+ #
84
+ # [Clase Antropometrico es un hijo de la clase Persona y representa los datos antropometricos de una persona]
85
+ #
86
+ # @author [Alexandra]
87
+ class Antropometrico < Persona
88
+
89
+ #getters y setters
90
+ attr_accessor :nombre, :apellido, :edad, :sexo, :peso, :talla
91
+
92
+ #
93
+ # [Descripcion del initialize]
94
+ # @param nombre [char] [name]
95
+ # @param apellido [char] [surname]
96
+ # @param edad [int] [age]
97
+ # @param sexo [int] [sex: 0= hombre, 1=mujer
98
+ # @param peso [int] [weight]
99
+ # @param talla [int] [size]
100
+ # @param cintura [list] [sizes of the body]
101
+ # @param cadera [list] [sizes of the body]
102
+ # @param tricipital [list] [sizes of the body]
103
+ # @param bicipital [list] [sizes of the body]
104
+ # @param subescapular [list] [sizes of the body]
105
+ # @param suprailiaco [list] [sizes of the body]
106
+ # @param brazo [list] [sizes of the body]
107
+ #
108
+ # @return [nil] [no returns]
109
+ def initialize(nombre, apellido, edad, sexo, peso, talla, cintura, cadera, tricipital, bicipital, subescapular, suprailiaco, brazo)
110
+ super(nombre, apellido, edad, sexo)
111
+ @peso, @talla, @cintura, @cadera, @tricipital, @bicipital, @subescapular, @suprailiaco, @brazo = peso, talla, cintura, cadera, tricipital, bicipital, subescapular, suprailiaco, brazo
112
+ end
113
+
114
+ #
115
+ # [peso_to_s]
116
+ #
117
+ # @return [string] [string of the calculates value]
118
+ def peso_to_s
119
+ "Peso: #{@peso}\n"
120
+ end
121
+
122
+ #
123
+ # [talla_to_s]
124
+ #
125
+ # @return [string] [string of the calculates value]
126
+ def talla_to_s
127
+ "Talla: #{@talla}\n"
128
+ end
129
+
130
+ #
131
+ # [cintura_to_s]
132
+ #
133
+ # @return [string] [string of the calculates value]
134
+ def cintura_to_s
135
+ return med_cintura(@cintura)
136
+ end
137
+
138
+ #
139
+ # [cadera_to_s]
140
+ #
141
+ # @return [string] [string of the calculates value]
142
+ def cadera_to_s
143
+ return med_cadera(@cadera)
144
+ end
145
+
146
+ #
147
+ # [med_cintura(cintura)]
148
+ #
149
+ # @return [string] [string of the calculates value]
150
+ def med_cintura(cintura)
151
+ # @cintura[]
152
+ s = 0
153
+ i = 0
154
+ while (i < cintura.length)
155
+ s += cintura[i]
156
+ i += 1
157
+ end
158
+ s = s/cintura.length
159
+ return s.round(2)
160
+ end
161
+
162
+ #
163
+ # [med_cadera(cadera)]
164
+ #
165
+ # @return [string] [string of the calculates value]
166
+ def med_cadera(cadera)
167
+
168
+ s = 0
169
+ i = 0
170
+ while (i < cadera.length)
171
+ s += cadera[i]
172
+ i += 1
173
+ end
174
+ s = s/cadera.length
175
+ return s.round(2)
176
+ end
177
+
178
+ #
179
+ # [tricipital_to_s]
180
+ #
181
+ # @return [string] [string of the calculates value]
182
+ def tricipital_to_s
183
+
184
+ s = 0
185
+ i = 0
186
+ while (i < @tricipital.length)
187
+ s += @tricipital[i]
188
+ i += 1
189
+ end
190
+ s = s/@tricipital.length
191
+ return s.round(2)
192
+ end
193
+
194
+ #
195
+ # [bicipital_to_s]
196
+ #
197
+ # @return [string] [string of the calculates value]
198
+ def bicipital_to_s
199
+
200
+ s = 0
201
+ i = 0
202
+ while (i < @bicipital.length)
203
+ s += @bicipital[i]
204
+ i += 1
205
+ end
206
+ s = s/@bicipital.length
207
+ return s.round(2)
208
+ end
209
+
210
+ #
211
+ # [subescapular_to_s]
212
+ #
213
+ # @return [string] [string of the calculates value]
214
+ def subescapular_to_s
215
+
216
+ s = 0
217
+ i = 0
218
+ while (i < @subescapular.length)
219
+ s += @subescapular[i]
220
+ i += 1
221
+ end
222
+ s = s/@subescapular.length
223
+ return s.round(2)
224
+ end
225
+
226
+ #
227
+ # [suprailiaco_to_s]
228
+ #
229
+ # @return [string] [string of the calculates value]
230
+ def suprailiaco_to_s
231
+
232
+ s = 0
233
+ i = 0
234
+ while (i < @suprailiaco.length)
235
+ s += @suprailiaco[i]
236
+ i += 1
237
+ end
238
+ s = s/@suprailiaco.length
239
+ return s.round(2)
240
+ end
241
+
242
+ #
243
+ # [imc of a person]
244
+ #
245
+ # @return [float] [imc]
246
+ def imc
247
+ return (@peso/(@talla * @talla)).round(2)
248
+ end
249
+
250
+ #
251
+ # [calculates the porc fat for the paciente]
252
+ #
253
+ # @return [float] [porc fat]
254
+ def porc_grasa
255
+ return (1.2 * imc + 0.23 * @edad - 10.8 * @sexo -5.4).round(2)
256
+ end
257
+
258
+ #
259
+ # [rcc of a person]
260
+ #
261
+ # @return [float] [rcc]
262
+ def rcc
263
+ aux = cintura_to_s()/cadera_to_s()
264
+ return aux.round(2)
265
+ end
266
+
267
+ #
268
+ # [brazo_to_s]
269
+ #
270
+ # @return [string] [string of the calculates value]
271
+ def brazo_to_s
272
+
273
+ s = 0
274
+ i = 0
275
+ while (i < @brazo.length)
276
+ s += @brazo[i]
277
+ i += 1
278
+ end
279
+ s = s/@brazo.length
280
+ return s.round(2)
281
+ end
282
+
283
+ #
284
+ # Compara los objetos sobre su imc
285
+ # @param other [object] [Person object]
286
+ #
287
+ # @return [bool] [true or false]
288
+ def <=>(other)
289
+ if other.is_a? Persona
290
+ imc <=> other.imc
291
+ else
292
+ false
293
+ end
294
+ end
295
+
296
+ #
297
+ # Devuelve el string representado por el objeto como un char
298
+ #
299
+ # @return [char] [name and surname as string]
300
+ def formato_to_s
301
+ puts "Nombre: #{@nombre}, Apellido: #{@apellido}, Edad: #{@edad}, Sexo: #{@sexo}, Peso: #{@peso}, Talla: #{@talla}, Cintura: #{@cintura}, Cadera: #{@cadera}, Tricipital: #{@tricipital}, Bicipital: #{@bicipital}, Subescapular: #{@subescapular}, Suprailiaco: #{@suprailiaco}, Brazo: #{@brazo}"
302
+ end
303
+
304
+ end
305
+ end
@@ -0,0 +1,3 @@
1
+ module Nutri
2
+ VERSION = "0.1.0"
3
+ end
data/nutri.gemspec ADDED
@@ -0,0 +1,47 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "nutri/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "menu_Alexandra"
8
+ spec.version = Nutri::VERSION
9
+ spec.authors = ["Alexandra Esplugas Sabina"]
10
+ spec.email = ["alu0100762006@ull.edu.es"]
11
+
12
+ spec.summary = %q{Implementar lenguaje DSL}
13
+ spec.description = %q{Clase Ruby para el tema de Programación Orientada a Objetos.}
14
+ spec.homepage = "https://github.com/ULL-ESIT-LPP-1819/unit-testing-alu0100762006.git"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata["https://rubygems.org"] = "TODO: Set to 'http://mygemserver.com'"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
23
+ spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against " \
26
+ "public gem pushes."
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_development_dependency "bundler", "~> 1.17"
39
+ spec.add_development_dependency "rake", "~> 10.0"
40
+ spec.add_development_dependency "rspec", "~> 3.0"
41
+
42
+ spec.add_development_dependency "guard"
43
+ spec.add_development_dependency "guard-rspec"
44
+ spec.add_development_dependency "guard-bundler"
45
+ spec.add_development_dependency "coveralls"
46
+
47
+ end
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: menu_Alexandra
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexandra Esplugas Sabina
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-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: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
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: Clase Ruby para el tema de Programación Orientada a Objetos.
112
+ email:
113
+ - alu0100762006@ull.edu.es
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".coveralls.yml"
119
+ - ".gitignore"
120
+ - ".rspec_status"
121
+ - ".travis.yml"
122
+ - CODE_OF_CONDUCT.md
123
+ - Gemfile
124
+ - Gemfile.lock
125
+ - Guardfile
126
+ - LICENSE.txt
127
+ - README.md
128
+ - Rakefile
129
+ - bin/console
130
+ - bin/setup
131
+ - lib/nutri.rb
132
+ - lib/nutri/dieta.rb
133
+ - lib/nutri/etiqueta.rb
134
+ - lib/nutri/lista.rb
135
+ - lib/nutri/menu.rb
136
+ - lib/nutri/persona.rb
137
+ - lib/nutri/version.rb
138
+ - nutri.gemspec
139
+ homepage: https://github.com/ULL-ESIT-LPP-1819/unit-testing-alu0100762006.git
140
+ licenses: []
141
+ metadata:
142
+ https://rubygems.org: 'TODO: Set to ''http://mygemserver.com'''
143
+ homepage_uri: https://github.com/ULL-ESIT-LPP-1819/unit-testing-alu0100762006.git
144
+ source_code_uri: 'TODO: Put your gem''s public repo URL here.'
145
+ changelog_uri: 'TODO: Put your gem''s CHANGELOG.md URL here.'
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubyforge_project:
162
+ rubygems_version: 2.6.11
163
+ signing_key:
164
+ specification_version: 4
165
+ summary: Implementar lenguaje DSL
166
+ test_files: []