menuNutrientes 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7bc7ec50c14d3a8f1ab414dcd5a096b15c206e55
4
+ data.tar.gz: a3e89a49b04fc13f47d69cb8b2c49a683c4064d1
5
+ SHA512:
6
+ metadata.gz: a89ac747de2d59cd5b94852a0d5333a04e96e10bb01acf243d4562568fb8507f29bff3c644285761956f7ff9ced6e21eea58144da39b19db2982229385516d0d
7
+ data.tar.gz: 7efc79973e4b091b1d67e55b4a7ea74d0ebbd52b73d6210b859630c2fe4b1017240e224035a6983b51af29064e32fbbd4b3bbbfe3c3aed3c39b7723e1ef731f2
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
+ menuNutrientes (0.1.0)
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
+ menuNutrientes!
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