InformacionNutricional 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,117 @@
1
+ # encoding: utf-8
2
+ # Author:: Ana de Lorenzo-Cáceres Luis (mailto:alu0100972016@ull.edu.es)
3
+ # Copyright:: Creative Commons
4
+ # License:: Distributes under the same terms as Ruby
5
+
6
+ require 'InformacionNutricional/persona.rb'
7
+
8
+ #Esta clase permite ver los datos de un paciente
9
+ #Es una subclase de la clase Persona
10
+ #Se ha incluido el mixin Comparable
11
+
12
+ class Paciente < Persona
13
+ include Comparable
14
+
15
+ #Getters de las variables de instancia
16
+ attr_reader :name, :weight, :height, :age, :waist, :hip, :imc, :rcc, :fat, :pliegues, :brazo, :medias, :media_brazo, :media_hip, :media_waist, :nivel_act_fis, :get
17
+
18
+ #Se genera el objeto con los datos proporcionados
19
+ def initialize(name, age, sexo, weight, height, waist, hip, tricipital, bicipital, subescapular, suprailiaco, brazo, nivel_act_fis)
20
+ super(name, age, sexo)
21
+ @weight, @height, @waist, @hip = weight, height, waist, hip
22
+ @pliegues = [tricipital, bicipital, subescapular, suprailiaco]
23
+ @brazo, @nivel_act_fis = brazo, nivel_act_fis
24
+ end
25
+
26
+ #Devuelve el imc del paciente
27
+ def calculo_imc
28
+ @imc = (@weight/@height**2).round(2)
29
+ end
30
+
31
+ #Devuelve el porcentaje de grasa del paciente
32
+ def porcentaje_fat
33
+ @fat = (1.2 * @imc + 0.23 * @age - 10.8 * @sex - 5.4).round(2)
34
+ end
35
+
36
+ #Devuelve las medidas de los pliegues del paciente
37
+ def calculo_pliegues
38
+ @medias = []
39
+ @pliegues.each do |pliegue|
40
+ suma = 0
41
+ pliegue.each do |elemento|
42
+ suma += elemento
43
+ end
44
+ @medias << (suma/pliegue.length).round(2)
45
+ end
46
+
47
+ suma_brazo = 0
48
+ @brazo.each do |elemento|
49
+ suma_brazo += elemento
50
+ end
51
+ @media_brazo = (suma_brazo/@brazo.length).round(2)
52
+
53
+ end
54
+
55
+ #Devuelve el RCC del paciente
56
+ def calculo_rcc
57
+ suma = 0
58
+ @waist.each do |elemento|
59
+ suma += elemento
60
+ end
61
+ @media_waist = suma/@waist.length
62
+ suma = 0
63
+ @hip.each do |elemento|
64
+ suma += elemento
65
+ end
66
+ @media_hip = suma/@hip.length
67
+ @rcc = (@media_waist/@media_hip).round(2)
68
+ end
69
+
70
+ #Devuelve el nivel de actividad física
71
+ def nivel_actividad
72
+ case @nivel_act_fis
73
+ when 1
74
+ @nivel_act_fis = 0.0
75
+ when 2
76
+ @nivel_act_fis = 0.12
77
+ when 3
78
+ @nivel_act_fis = 0.27
79
+ when 4
80
+ @nivel_act_fis = 0.54
81
+ end
82
+ end
83
+
84
+ #Devuelve el gasto energético total
85
+ def gasto_energetico
86
+ basal = (10 * @weight) + (6.25 * @height) - (5 * @age)
87
+ if sex == 0
88
+ basal -= 161
89
+ else
90
+ basal += 5
91
+ end
92
+ termogeno = basal * 0.10
93
+ actividad = basal * @nivel_act_fis
94
+ @get = (basal + termogeno + actividad).round(2)
95
+ end
96
+
97
+ #Override del to_s
98
+ def to_s
99
+ array = super()
100
+ array += ", IMC: #{@imc}, Grasa: #{@fat}%, Tricipital: #{@medias[0]}, Bicipital: #{@medias[1]}, Subescapular: #{@medias[2]}, Suprailíaco: #{@medias[3]}, Brazo: #{@media_brazo}, RCC: #{@rcc}"
101
+ end
102
+
103
+ #Se define para incluir el mixin Comparable
104
+ #Se toma como valor para la comparación el imc de los pacientes
105
+ #(Valor que devuelve la función calculo_imc)
106
+ def <=> (other)
107
+ return nil unless other.is_a?Paciente
108
+ gasto_energetico <=> other.gasto_energetico
109
+ end
110
+
111
+ #Override del ==
112
+ #Se toman para considerar iguales: nombre, imc y rcc
113
+ def == (other)
114
+ return nil unless other.is_a?Paciente
115
+ (@name == other.name) && (calculo_imc == other.calculo_imc) && (calculo_rcc == other.calculo_rcc)
116
+ end
117
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+ # Author:: Ana de Lorenzo-Cáceres Luis (mailto:alu0100972016@ull.edu.es)
3
+ # Copyright:: Creative Commons
4
+ # License:: Distributes under the same terms as Ruby
5
+
6
+ #Esta clase permite ver los datos de una persona
7
+ class Persona
8
+
9
+ #Getters de las variables de instancia
10
+ attr_reader :name, :age
11
+
12
+ #Se genera el objeto con los datos proporcionados
13
+ def initialize(name, age, sex)
14
+ @name, @age, @sex = name, age, sex
15
+ end
16
+
17
+ #Devuelve un string para identificar el sexo
18
+ def sex
19
+ array = ""
20
+ if @sex == 1
21
+ array = "Hombre"
22
+ else
23
+ array = "Mujer"
24
+ end
25
+ array
26
+ end
27
+
28
+ #Override del to_s
29
+ def to_s
30
+ "Nombre: #{@name}, Edad: #{@age}, Sexo: #{sex}"
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module InformacionNutricional
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: InformacionNutricional
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ana Cáceres
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: ''
112
+ email:
113
+ - alu0100972016@ull.edu.es
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".coveralls.yml"
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".travis.yml"
122
+ - Gemfile
123
+ - Gemfile.lock
124
+ - Guardfile
125
+ - InformacionNutricional.gemspec
126
+ - README.md
127
+ - Rakefile
128
+ - bin/console
129
+ - bin/setup
130
+ - doc/Etiqueta.html
131
+ - doc/InformacionNutricional.html
132
+ - doc/InformacionNutricional/Error.html
133
+ - doc/List.html
134
+ - doc/Node.html
135
+ - doc/Paciente.html
136
+ - doc/Persona.html
137
+ - doc/_index.html
138
+ - doc/class_list.html
139
+ - doc/css/common.css
140
+ - doc/css/full_list.css
141
+ - doc/css/style.css
142
+ - doc/file.README.html
143
+ - doc/file_list.html
144
+ - doc/frames.html
145
+ - doc/index.html
146
+ - doc/js/app.js
147
+ - doc/js/full_list.js
148
+ - doc/js/jquery.js
149
+ - doc/method_list.html
150
+ - doc/top-level-namespace.html
151
+ - lib/InformacionNutricional.rb
152
+ - lib/InformacionNutricional/array.rb
153
+ - lib/InformacionNutricional/etiqueta.rb
154
+ - lib/InformacionNutricional/list.rb
155
+ - lib/InformacionNutricional/menu.rb
156
+ - lib/InformacionNutricional/paciente.rb
157
+ - lib/InformacionNutricional/persona.rb
158
+ - lib/InformacionNutricional/version.rb
159
+ homepage: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100972016.git
160
+ licenses: []
161
+ metadata:
162
+ allowed_push_host: https://rubygems.org
163
+ homepage_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100972016.git
164
+ source_code_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100972016.git
165
+ changelog_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100972016.git
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ requirements: []
181
+ rubyforge_project:
182
+ rubygems_version: 2.7.7
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: Esto es una gema que representa la información nutricional de un alimento
186
+ test_files: []