menuNutricional 0.3.15

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c11c4b5acd3f0305144aae0f729876eed560aac9
4
+ data.tar.gz: abcd68b1d4ba08a64ac224d794fae301221e6c3d
5
+ SHA512:
6
+ metadata.gz: 25cf24b7a0065d4a4436808551fc603f23320956e898fc28831c8968f49ce74b5b5c838384938e86d1db7b4e03f2bf1c5f82608f7d95d2f74c6ba0f3fa2c462c
7
+ data.tar.gz: dbaa8e08faa485cdf7cc5b57a3942484348090ce7832ab89c9fe20e14c381d12e466b34a66d9d8ca038b2be60bdcb85cbaf52eb6d3a836effa86b9de767df774
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.3.0
7
+ before_install: gem install bundler -v 1.17.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in nutrientes.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,111 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ menuNutricional (0.3.15)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.2)
10
+ coveralls (0.7.1)
11
+ multi_json (~> 1.3)
12
+ rest-client
13
+ simplecov (>= 0.7)
14
+ term-ansicolor
15
+ thor
16
+ diff-lcs (1.3)
17
+ docile (1.3.1)
18
+ domain_name (0.5.20180417)
19
+ unf (>= 0.0.5, < 1.0.0)
20
+ ffi (1.9.25)
21
+ formatador (0.2.5)
22
+ guard (2.15.0)
23
+ formatador (>= 0.2.4)
24
+ listen (>= 2.7, < 4.0)
25
+ lumberjack (>= 1.0.12, < 2.0)
26
+ nenv (~> 0.1)
27
+ notiffany (~> 0.0)
28
+ pry (>= 0.9.12)
29
+ shellany (~> 0.0)
30
+ thor (>= 0.18.1)
31
+ guard-bundler (2.1.0)
32
+ bundler (~> 1.0)
33
+ guard (~> 2.2)
34
+ guard-compat (~> 1.1)
35
+ guard-compat (1.2.1)
36
+ guard-rspec (4.7.3)
37
+ guard (~> 2.1)
38
+ guard-compat (~> 1.1)
39
+ rspec (>= 2.99.0, < 4.0)
40
+ http-cookie (1.0.3)
41
+ domain_name (~> 0.5)
42
+ json (2.1.0)
43
+ listen (3.1.5)
44
+ rb-fsevent (~> 0.9, >= 0.9.4)
45
+ rb-inotify (~> 0.9, >= 0.9.7)
46
+ ruby_dep (~> 1.2)
47
+ lumberjack (1.0.13)
48
+ method_source (0.9.2)
49
+ mime-types (3.2.2)
50
+ mime-types-data (~> 3.2015)
51
+ mime-types-data (3.2018.0812)
52
+ multi_json (1.13.1)
53
+ nenv (0.3.0)
54
+ netrc (0.11.0)
55
+ notiffany (0.1.1)
56
+ nenv (~> 0.1)
57
+ shellany (~> 0.0)
58
+ pry (0.12.2)
59
+ coderay (~> 1.1.0)
60
+ method_source (~> 0.9.0)
61
+ rake (10.4.2)
62
+ rb-fsevent (0.10.3)
63
+ rb-inotify (0.9.10)
64
+ ffi (>= 0.5.0, < 2)
65
+ rest-client (2.0.2)
66
+ http-cookie (>= 1.0.2, < 2.0)
67
+ mime-types (>= 1.16, < 4.0)
68
+ netrc (~> 0.8)
69
+ rspec (3.8.0)
70
+ rspec-core (~> 3.8.0)
71
+ rspec-expectations (~> 3.8.0)
72
+ rspec-mocks (~> 3.8.0)
73
+ rspec-core (3.8.0)
74
+ rspec-support (~> 3.8.0)
75
+ rspec-expectations (3.8.2)
76
+ diff-lcs (>= 1.2.0, < 2.0)
77
+ rspec-support (~> 3.8.0)
78
+ rspec-mocks (3.8.0)
79
+ diff-lcs (>= 1.2.0, < 2.0)
80
+ rspec-support (~> 3.8.0)
81
+ rspec-support (3.8.0)
82
+ ruby_dep (1.5.0)
83
+ shellany (0.0.1)
84
+ simplecov (0.16.1)
85
+ docile (~> 1.1)
86
+ json (>= 1.8, < 3)
87
+ simplecov-html (~> 0.10.0)
88
+ simplecov-html (0.10.2)
89
+ term-ansicolor (1.7.0)
90
+ tins (~> 1.0)
91
+ thor (0.20.3)
92
+ tins (1.20.2)
93
+ unf (0.1.4)
94
+ unf_ext
95
+ unf_ext (0.0.7.5)
96
+
97
+ PLATFORMS
98
+ ruby
99
+
100
+ DEPENDENCIES
101
+ bundler (~> 1.17)
102
+ coveralls
103
+ guard
104
+ guard-bundler
105
+ guard-rspec
106
+ nutrientes!
107
+ rake (~> 10.0)
108
+ rspec (~> 3.0)
109
+
110
+ BUNDLED WITH
111
+ 1.17.1
data/Guardfile ADDED
@@ -0,0 +1,82 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ guard :bundler do
19
+ require 'guard/bundler'
20
+ require 'guard/bundler/verify'
21
+ helper = Guard::Bundler::Verify.new
22
+
23
+ files = ['Gemfile']
24
+ files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
25
+
26
+ # Assume files are symlinked from somewhere
27
+ files.each { |file| watch(helper.real_path(file)) }
28
+ end
29
+
30
+ # Note: The cmd option is now required due to the increasing number of ways
31
+ # rspec may be run, below are examples of the most common uses.
32
+ # * bundler: 'bundle exec rspec'
33
+ # * bundler binstubs: 'bin/rspec'
34
+ # * spring: 'bin/rspec' (This will use spring if running and you have
35
+ # installed the spring binstubs per the docs)
36
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
37
+ # * 'just' rspec: 'rspec'
38
+
39
+ guard :rspec, cmd: "bundle exec rspec" do
40
+ require "guard/rspec/dsl"
41
+ dsl = Guard::RSpec::Dsl.new(self)
42
+
43
+ # Feel free to open issues for suggestions and improvements
44
+
45
+ # RSpec files
46
+ rspec = dsl.rspec
47
+ watch(rspec.spec_helper) { rspec.spec_dir }
48
+ watch(rspec.spec_support) { rspec.spec_dir }
49
+ watch(rspec.spec_files)
50
+
51
+ # Ruby files
52
+ ruby = dsl.ruby
53
+ dsl.watch_spec_files_for(ruby.lib_files)
54
+
55
+ # Rails files
56
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
57
+ dsl.watch_spec_files_for(rails.app_files)
58
+ dsl.watch_spec_files_for(rails.views)
59
+
60
+ watch(rails.controllers) do |m|
61
+ [
62
+ rspec.spec.call("routing/#{m[1]}_routing"),
63
+ rspec.spec.call("controllers/#{m[1]}_controller"),
64
+ rspec.spec.call("acceptance/#{m[1]}")
65
+ ]
66
+ end
67
+
68
+ # Rails config changes
69
+ watch(rails.spec_helper) { rspec.spec_dir }
70
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
71
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
72
+
73
+ # Capybara features specs
74
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
75
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
76
+
77
+ # Turnip features and steps
78
+ watch(%r{^spec/acceptance/(.+)\.feature$})
79
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
80
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
81
+ end
82
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 bolften
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README ADDED
File without changes
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Nutrientes
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/nutrientes`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'nutrientes'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install nutrientes
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/nutrientes.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "nutrientes"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,80 @@
1
+ # @author Carlos Arvelo Garcia (alu0100943849)
2
+
3
+ require 'nutrientes/version'
4
+ require 'Individuo'
5
+
6
+ #Clase Antropometrico almacena los datos del paciente
7
+
8
+ class Antropometrico
9
+
10
+ include Comparable
11
+
12
+ attr_reader :peso, :talla, :edad, :sexo, :cintura, :cadera
13
+
14
+ def initialize(sexo, peso,talla,edad,cintura,cadera)
15
+ @sexo = sexo
16
+ @peso = peso
17
+ @talla = talla
18
+ @edad = edad
19
+ @cintura = cintura
20
+ @cadera = cadera
21
+ end
22
+
23
+ # Calcula el indice de masa corporal mediante la funcion (peso/(talla^2))
24
+ #
25
+ # == Parameters:
26
+ # No recibe parametros
27
+ #
28
+ # == Returns:
29
+ # Una variable con el resultado de la operación
30
+ def indice_masa_corporal
31
+ @imc = @peso / (@talla * @talla)
32
+ @imc.round(1)
33
+ end
34
+
35
+ # Calcula el porcentaje de grasa mediante la funcion (1,2 × IMC + 0,23 × edad − 10,8 × sexo − 5,4)
36
+ #
37
+ # == Parameters:
38
+ # No recibe parametros
39
+ #
40
+ # == Returns:
41
+ # Una variable con el resultado de la operación
42
+ def porcentaje_grasa
43
+ @resul = (1.2 * ( @peso / (@talla * @talla) )) + (0.23 * @edad) - (10.8 * @sexo) - 5.4
44
+ @resul.round(2)
45
+ end
46
+
47
+ # Calcula la relacion entre circunferencia de cadera y cintura mediante la funcion (cir. cintura / cir cadera)
48
+ #
49
+ # == Parameters:
50
+ # No recibe parametros
51
+ #
52
+ # == Returns:
53
+ # Una variable con el resultado de la operación
54
+ def rCC
55
+ @rcc = (@cintura/@cadera)
56
+ @rcc.round(2)
57
+ end
58
+
59
+ # Define el metodo para compara elementos de tipo Antropometrico
60
+ #
61
+ # == Parameters:
62
+ # Recibe un parametro de tipo Antropometrico
63
+ #
64
+ # == Returns:
65
+ # Un balor booleano dependiendo del resultado de la operacion
66
+ def <=>(other)
67
+ indice_masa_corporal <=> other.indice_masa_corporal
68
+ end
69
+
70
+ # Define el metodo para imprimir por pantalla
71
+ #
72
+ # == Parameters:
73
+ # No recibe ninguno
74
+ #
75
+ # == Returns:
76
+ # Un string con el contenido de las variables
77
+ def to_s
78
+ "#{@imc}, #{@resul}, #{@rcc}"
79
+ end
80
+ end
@@ -0,0 +1,232 @@
1
+ # @author Carlos Arvelo Garcia (alu0100943849)
2
+
3
+ require 'nutrientes/version'
4
+
5
+ #Struct Node almacena los datos antropometricos
6
+
7
+ Node = Struct.new(:value, :next, :prev)
8
+
9
+ #Clase DlinkedList almacena los datos en una lista
10
+
11
+ class DlinkedList
12
+
13
+ include Enumerable
14
+
15
+ attr_reader :head, :tail
16
+
17
+ def initialize()
18
+
19
+ @head = @tail = nil
20
+
21
+ end
22
+
23
+ # Inserta por la cola de la lista un nodo
24
+ #
25
+ # == Parameters:
26
+ # Recive un valor o dato que se quiera insertar
27
+ #
28
+ # == Returns:
29
+ # No retorna nada
30
+ def insertTail(value)
31
+
32
+ n = Node.new(value)
33
+
34
+ if @head.nil?
35
+
36
+ @tail = n
37
+ @head = @tail
38
+
39
+ else
40
+
41
+ @tail.next = n
42
+ n.prev = @tail
43
+ @tail = n
44
+
45
+ end
46
+
47
+ end
48
+
49
+ # Inserta por la cabeza de la lista un nodo
50
+ #
51
+ # == Parameters:
52
+ # Recive un valor o dato que se quiera insertar
53
+ #
54
+ # == Returns:
55
+ # No retorna nada
56
+ def insertHead(value)
57
+
58
+ n = Node.new(value)
59
+
60
+ if @head.nil?
61
+
62
+ @head = n
63
+ @tail = @head
64
+
65
+ else
66
+
67
+ @head.next = n
68
+ n.prev = @head
69
+ @head = n
70
+
71
+ end
72
+
73
+ end
74
+
75
+ # Extrae por la cabeza de la lista un nodo
76
+ #
77
+ # == Parameters:
78
+ # No recibe nada
79
+ #
80
+ # == Returns:
81
+ # Retorna el nodo extraido
82
+ def popHead
83
+
84
+ unless @head.nil?
85
+
86
+ aux = @head
87
+ unless @head.next.nil?
88
+
89
+ @head.next.prev = nil
90
+ @head = @head.next
91
+
92
+ else
93
+
94
+ @head = nil
95
+ @tail = nil
96
+
97
+ end
98
+ aux
99
+
100
+ end
101
+
102
+ end
103
+
104
+ # Extrae por la cola de la lista un nodo
105
+ #
106
+ # == Parameters:
107
+ # No recibe nada
108
+ #
109
+ # == Returns:
110
+ # Retorna el nodo extraido
111
+ def popTail
112
+
113
+ unless @tail.nil?
114
+
115
+ aux = @tail
116
+ unless @tail.prev.nil?
117
+
118
+ @tail.prev.next = nil
119
+ @tail = @tail.prev
120
+
121
+ else
122
+
123
+ @head = nil
124
+ @tail = nil
125
+
126
+ end
127
+ aux
128
+
129
+ end
130
+
131
+ end
132
+
133
+ # Extrae por la cabeza de la lista todos los nodos que quedan en la lista si no esta vacia
134
+ #
135
+ # == Parameters:
136
+ # No recibe nada
137
+ #
138
+ # == Returns:
139
+ # Retorna los nodos extraidos
140
+ def removeAll
141
+
142
+ unless @head.nil?
143
+
144
+ while @head != nil
145
+
146
+ aux = @head.next
147
+ self.popHead
148
+ @head = aux
149
+ aux
150
+ end
151
+
152
+ end
153
+
154
+ end
155
+
156
+ # Recorre la lista desde la cabeza hasta a cola
157
+ #
158
+ # == Parameters:
159
+ # No recibe nada
160
+ #
161
+ # == Returns:
162
+ # No retorna nada
163
+ def each
164
+
165
+ nodo = @head
166
+ while nodo != nil
167
+
168
+ yield nodo.value
169
+ nodo = nodo.next
170
+
171
+ end
172
+
173
+ end
174
+
175
+ # Define el metodo para imprimir por pantalla
176
+ #
177
+ # == Parameters:
178
+ # No recibe ninguno
179
+ #
180
+ # == Returns:
181
+ # Un string con el contenido de las variables
182
+ def to_s
183
+
184
+ each {|x| puts x}
185
+
186
+ end
187
+
188
+ def ordenarFor
189
+ arrayOrd = []
190
+ for nodo in self
191
+ if arrayOrd.empty?
192
+ arrayOrd.push(nodo)
193
+ else
194
+ indice = 0
195
+ while indice < arrayOrd.length
196
+ if nodo <= arrayOrd[indice]
197
+ arrayOrd.insert(indice, nodo)
198
+ break
199
+ elsif indice == arrayOrd.length-1
200
+ arrayOrd.insert(indice+1, nodo)
201
+ break
202
+ end
203
+ indice+=1
204
+ end
205
+ end
206
+ end
207
+ return arrayOrd
208
+ end
209
+
210
+ def ordenarEach
211
+ arrayOrd = []
212
+ each do |nodo|
213
+ if arrayOrd.empty?
214
+ arrayOrd.push(nodo)
215
+ else
216
+ indice = 0
217
+ while indice < arrayOrd.length
218
+ if nodo <= arrayOrd[indice]
219
+ arrayOrd.insert(indice, nodo)
220
+ break
221
+ elsif indice == arrayOrd.length-1
222
+ arrayOrd.insert(indice+1, nodo)
223
+ break
224
+ end
225
+ indice+=1
226
+ end
227
+ end
228
+ end
229
+ return arrayOrd
230
+ end
231
+
232
+ end
data/lib/Individuo.rb ADDED
@@ -0,0 +1,186 @@
1
+ # @author Carlos Arvelo Garcia (alu0100943849)
2
+
3
+ require 'nutrientes/version'
4
+ require 'Antropometrico'
5
+
6
+ #Clase Individuo almacena los datos de un individuo
7
+
8
+ class Individuo
9
+
10
+ include Comparable
11
+
12
+ attr_reader :nombre
13
+
14
+ def initialize(nombre)
15
+ @nombre = nombre
16
+ @datos = nil
17
+ end
18
+
19
+ # Comprueba si el Tipo de un objeto es de tipo Individuo
20
+ #
21
+ # == Parameters:
22
+ # Recibe un objeto
23
+ #
24
+ # == Returns:
25
+ # Retorna true o false
26
+ def es(other)
27
+ if other.is_a? Individuo
28
+ @nombre == other.nombre
29
+ elsif
30
+ false
31
+ end
32
+ end
33
+
34
+ # Define el metodo para imprimir por pantalla
35
+ #
36
+ # == Parameters:
37
+ # No recibe ninguno
38
+ #
39
+ # == Returns:
40
+ # Un string con el contenido de las variables
41
+ def to_s
42
+ "#{nombre}"
43
+ end
44
+
45
+
46
+ end
47
+
48
+ class Pacientes < Individuo
49
+
50
+ attr_reader :datos, :actividad_fisica
51
+
52
+ def initialize(nombre,datos, actividad_fisica)
53
+ super(nombre)
54
+ @datos = datos #datos antropometricos
55
+ @actividad_fisica = actividad_fisica
56
+ end
57
+
58
+ def ==(other)
59
+ if other.is_a? Individuo
60
+ nombre == other.nombre
61
+ elsif
62
+ false
63
+ end
64
+ end
65
+
66
+ # Comprueba entre que valores esta el icm de un pacuente y determina su estado corporal
67
+ #
68
+ # == Parameters:
69
+ # No recibe ninguno
70
+ #
71
+ # == Returns:
72
+ # Un string con el peso del paciente
73
+ def indice_corporal
74
+ if @datos.indice_masa_corporal <= 18.5
75
+ "Bajo peso"
76
+ elsif @datos.indice_masa_corporal > 18.5 and @datos.indice_masa_corporal <= 24.9
77
+ "Peso adecuado"
78
+ elsif @datos.indice_masa_corporal > 25.0 and @datos.indice_masa_corporal <= 29.9
79
+ "Sobrepeso"
80
+ elsif @datos.indice_masa_corporal > 30.0 and @datos.indice_masa_corporal <= 34.9
81
+ "Obesidad grado 1"
82
+ elsif @datos.indice_masa_corporal > 35.0 and @datos.indice_masa_corporal <= 39.9
83
+ "Obesidad grado 2"
84
+ elsif @datos.indice_masa_corporal > 40
85
+ "Obesidad grado 3"
86
+ end
87
+ end
88
+
89
+ # Define el metodo para calcular el peso teorico ideal
90
+ #
91
+ # == Parameters:
92
+ # No recibe ninguno
93
+ #
94
+ # == Returns:
95
+ # Un float con el resultado de la operacion
96
+ def peso_teorico_ideal
97
+ ((@datos.talla * 100) - 150) * 0.75 + 50
98
+ end
99
+
100
+ # Define el metodo para calcular el gasto_energetico_basal
101
+ #
102
+ # == Parameters:
103
+ # No recibe ninguno
104
+ #
105
+ # == Returns:
106
+ # Un float con el resultado de la operacion
107
+ def gasto_energetico_basal
108
+
109
+ if @datos.sexo == 0
110
+
111
+ (10 * @datos.peso) + (6.25 * @datos.talla) - (5 * @datos.edad) - 161
112
+
113
+ elsif @datos.sexo == 1
114
+
115
+ (10 * @datos.peso) + (6.25 * @datos.talla) - (5 * @datos.edad) + 5
116
+
117
+ end
118
+
119
+ end
120
+
121
+ # Define el metodo para calcular el efecto_termogeno
122
+ #
123
+ # == Parameters:
124
+ # No recibe ninguno
125
+ #
126
+ # == Returns:
127
+ # Un float con el resultado de la operacion
128
+ def efecto_termogeno
129
+
130
+ gasto_energetico_basal * 0.10
131
+
132
+ end
133
+
134
+ # Define el metodo para calcular el gasto_actividad_fisica
135
+ #
136
+ # == Parameters:
137
+ # No recibe ninguno
138
+ #
139
+ # == Returns:
140
+ # Un float con el resultado de la operacion
141
+ def gasto_actividad_fisica
142
+
143
+ if @actividad_fisica == "reposo"
144
+ gasto_energetico_basal * 0.0
145
+ elsif @actividad_fisica == "ligera"
146
+ gasto_energetico_basal * 0.12
147
+ elsif @actividad_fisica == "moderada"
148
+ gasto_energetico_basal * 0.27
149
+ elsif @actividad_fisica == "intensa"
150
+ gasto_energetico_basal * 0.54
151
+ end
152
+
153
+ end
154
+
155
+ # Define el metodo para calcular el gasto_energetico_total
156
+ #
157
+ # == Parameters:
158
+ # No recibe ninguno
159
+ #
160
+ # == Returns:
161
+ # Un float con el resultado de la operacion
162
+ def gasto_energetico_total
163
+
164
+ gasto_energetico_basal + efecto_termogeno + gasto_actividad_fisica
165
+
166
+ end
167
+
168
+ def <=>(other)
169
+ gasto_energetico_total <=> other.gasto_energetico_total
170
+ end
171
+
172
+ # Define el metodo para imprimir por pantalla
173
+ #
174
+ # == Parameters:
175
+ # No recibe ninguno
176
+ #
177
+ # == Returns:
178
+ # Un string con el contenido de las variables
179
+ def to_s
180
+ "#{@datos.indice_masa_corporal}"
181
+ end
182
+
183
+ end
184
+
185
+
186
+
@@ -0,0 +1,172 @@
1
+ # @author Carlos Arvelo Garcia (alu0100943849)
2
+
3
+ require 'nutrientes/version'
4
+ require 'DlinkedList'
5
+
6
+ #Clase Nutricional_label almacena los datos de los alimentos
7
+
8
+ class Nutricional_label
9
+
10
+ include Comparable
11
+
12
+ attr_reader :nombre_etiqueta, :grasa, :grasa_saturada, :hid_carbono, :azucares, :proteinas, :sal
13
+
14
+ def initialize(nombre_etiqueta,grasa,grasa_saturada,hid_carbono,azucares,proteinas,sal)
15
+ @nombre_etiqueta = nombre_etiqueta
16
+ @grasa = grasa
17
+ @grasa_saturada = grasa_saturada
18
+ @hid_carbono = hid_carbono
19
+ @azucares = azucares
20
+ @proteinas = proteinas
21
+ @sal = sal
22
+ end
23
+
24
+ # nombre de la comida
25
+ #
26
+ # == Parameters:
27
+ # No recibe parametros
28
+ #
29
+ # == Returns:
30
+ # el nombre de la etiqueta almacenado el la variable nombre_etiqueta
31
+ def label_name
32
+
33
+ "#{nombre_etiqueta}"
34
+
35
+ end
36
+
37
+ # Calcula el valor energetico de un alimento en KJ
38
+ #
39
+ # == Parameters:
40
+ # No recibe parametros
41
+ #
42
+ # == Returns:
43
+ # Una variable con el resultado de la operación
44
+ def energetic_value_KJ
45
+ @kj = (@grasa * 37) + (@grasa_saturada * 37) + (@hid_carbono * 17) + (@azucares * 17) + (@proteinas * 17) + (@sal * 25)
46
+ end
47
+
48
+ # Calcula el valor energetico de un alimento en Kcal
49
+ #
50
+ # == Parameters:
51
+ # No recibe parametros
52
+ #
53
+ # == Returns:
54
+ # Una variable con el resultado de la operación
55
+ def energetic_value_Kcal
56
+ @kcal = (@grasa * 9) + (@grasa_saturada * 9) + (@hid_carbono * 4) + (@azucares * 4) + (@proteinas * 4) + (@sal * 6)
57
+ end
58
+
59
+ # Imprime la etiqueta de informacion nutricional del alimento
60
+ #
61
+ # == Parameters:
62
+ # No recibe parametros
63
+ #
64
+ # == Returns:
65
+ # No retorna nada
66
+ def print_label
67
+ puts "#{@nombre_etiqueta}"
68
+ puts "\nValor energetico o nutriente | por 100g o 100ml de producto "
69
+ puts "--------------------------------|--------------------------------"
70
+ puts "valor energetico |" + " #{energetic_value_KJ}" + " KJ/" + "#{energetic_value_Kcal}" + " Kcal"
71
+ puts "Camtidad de grasas |" + " #{@grasa}g"
72
+ puts "Camtidad de grasas saturadas |" + " #{@grasa_saturada}g"
73
+ puts "Camtidad de hidratos de carbono |" + " #{@hid_carbono}g"
74
+ puts "Camtidad de azucares |" + " #{@azucares}g"
75
+ puts "Camtidad de proteinas |" + " #{@proteinas}g"
76
+ puts "Camtidad de sal |" + " #{@sal}g"
77
+ @nombre_etiqueta
78
+ end
79
+
80
+ # Define el metodo para compara elementos de tipo Nutricional_label
81
+ #
82
+ # == Parameters:
83
+ # Recibe un parametro de tipo Nutricional_label
84
+ #
85
+ # == Returns:
86
+ # Un valor booleano dependiendo del resultado de la operacion
87
+ def <=>(other)
88
+ energetic_value_Kcal <=> other.energetic_value_Kcal
89
+ end
90
+
91
+ # Indica la cantidad de sal que tiene el alimento
92
+ #
93
+ # == Parameters:
94
+ # Recibe un parametro de tipo Nutricional_label
95
+ #
96
+ # == Returns:
97
+ # Un string
98
+ def clasificar
99
+ if @sal <= 1
100
+ "poca"
101
+ elsif @sal > 1 and @sal <= 2
102
+ "media"
103
+ elsif @sal > 2
104
+ "mucha"
105
+ end
106
+ end
107
+
108
+ # Define el metodo para imprimir por pantalla
109
+ #
110
+ # == Parameters:
111
+ # No recibe ninguno
112
+ #
113
+ # == Returns:
114
+ # Un string con el contenido de las variables
115
+ def to_s
116
+
117
+ "#{@kcal}"
118
+
119
+ end
120
+
121
+ end
122
+
123
+
124
+ def ordenarArrayEach(lista_menus)
125
+ arrayOrd = []
126
+ lista_menus.each do |menus|
127
+ if arrayOrd.empty?
128
+ arrayOrd.push(menus)
129
+ else
130
+ indice = 0
131
+ while indice < arrayOrd.length
132
+ energia = menus.reduce(0) {|sum, val_ener| sum + val_ener.energetic_value_Kcal}
133
+ energia_siguiente = arrayOrd[indice].reduce(0) {|sum, val_ener| sum + val_ener.energetic_value_Kcal}
134
+ if energia <= energia_siguiente
135
+ arrayOrd.insert(indice, menus)
136
+ break
137
+ elsif indice == arrayOrd.length-1
138
+ arrayOrd.insert(indice+1, menus)
139
+ break
140
+ end
141
+ indice+=1
142
+ end
143
+ end
144
+ end
145
+ return arrayOrd
146
+
147
+ end
148
+
149
+ def ordenarArrayFor(lista_menus)
150
+ arrayOrd = []
151
+ for menus in lista_menus
152
+ if arrayOrd.empty?
153
+ arrayOrd.push(menus)
154
+ else
155
+ indice = 0
156
+ while indice < arrayOrd.length
157
+ energia = menus.reduce(0) {|sum, val_ener| sum + val_ener.energetic_value_Kcal}
158
+ energia_siguiente = arrayOrd[indice].reduce(0) {|sum, val_ener| sum + val_ener.energetic_value_Kcal}
159
+ if energia <= energia_siguiente
160
+ arrayOrd.insert(indice, menus)
161
+ break
162
+ elsif indice == arrayOrd.length-1
163
+ arrayOrd.insert(indice+1, menus)
164
+ break
165
+ end
166
+ indice+=1
167
+ end
168
+ end
169
+ end
170
+ return arrayOrd
171
+
172
+ end
data/lib/nutrientes.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "nutrientes/version"
2
+
3
+ module Nutrientes
4
+ class Error < StandardError; end
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,3 @@
1
+ module Nutrientes
2
+ VERSION = "0.3.15"
3
+ end
@@ -0,0 +1,46 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "nutrientes/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "menuNutricional"
8
+ spec.version = Nutrientes::VERSION
9
+ spec.authors = ["Carlos Arvelo Garcia"]
10
+ spec.email = ["alu0100943849@ull.edu.es"]
11
+
12
+ spec.summary = %q{"Practica 12"}
13
+ spec.homepage = "https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100943849"
14
+ spec.license = "MIT"
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["allowed_push_host"] = "https://rubygems.org"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100943849"
23
+ else
24
+ raise "RubyGems 2.0 or newer is required to protect against " \
25
+ "public gem pushes."
26
+ end
27
+
28
+ # Specify which files should be added to the gem when it is released.
29
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
31
+ `git ls-files -z`.split("\x0").reject { |f| 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.17"
38
+ spec.add_development_dependency "rake", "~> 10.0"
39
+ spec.add_development_dependency "rspec", "~> 3.0"
40
+
41
+ spec.add_development_dependency "guard"
42
+ spec.add_development_dependency "guard-rspec"
43
+ spec.add_development_dependency "guard-bundler"
44
+
45
+ spec.add_development_dependency "coveralls"
46
+ end
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: menuNutricional
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.15
5
+ platform: ruby
6
+ authors:
7
+ - Carlos Arvelo Garcia
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
+ - alu0100943849@ull.edu.es
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".coveralls.yml"
119
+ - ".gitignore"
120
+ - ".travis.yml"
121
+ - Gemfile
122
+ - Gemfile.lock
123
+ - Guardfile
124
+ - LICENSE.txt
125
+ - README
126
+ - README.md
127
+ - Rakefile
128
+ - bin/console
129
+ - bin/setup
130
+ - lib/Antropometrico.rb
131
+ - lib/DlinkedList.rb
132
+ - lib/Individuo.rb
133
+ - lib/Nutricional_label.rb
134
+ - lib/nutrientes.rb
135
+ - lib/nutrientes/version.rb
136
+ - menuNutricional.gemspec
137
+ homepage: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100943849
138
+ licenses:
139
+ - MIT
140
+ metadata:
141
+ allowed_push_host: https://rubygems.org
142
+ homepage_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100943849
143
+ source_code_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100943849
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ requirements: []
159
+ rubyforge_project:
160
+ rubygems_version: 2.6.8
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: '"Practica 12"'
164
+ test_files: []