alu0100406580_nutricion 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c031bc69d050dc0c897238cfdd6c256bf7b6d15f79d8c0f9263575e1f2960f6d
4
+ data.tar.gz: a1feffea923017e5107af4db190ed7f203ed26a7231a81b0b4b01e9493a506b3
5
+ SHA512:
6
+ metadata.gz: 3b362b23aa82ac4a00e5ebdb07c8069991a58cd80e60fdaa8dba5cbccba5e7e356b0e7cddf0346bacd8574ad8c19a5e12aa883adb9a8bdf57f8964e949b46f90
7
+ data.tar.gz: b253ce50a85a45a9c2638277af501dbfbd21019f3dfe96302041c35041d03f06f6d5dcfed7b25ae8c85763dc427545082423092e7b10100bd0f625eea1cac444
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/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
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 alu0100406580_nutricion.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,97 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ alu0100406580_nutricion (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.2)
10
+ coveralls (0.8.22)
11
+ json (>= 1.8, < 3)
12
+ simplecov (~> 0.16.1)
13
+ term-ansicolor (~> 1.3)
14
+ thor (~> 0.19.4)
15
+ tins (~> 1.6)
16
+ diff-lcs (1.3)
17
+ docile (1.3.1)
18
+ ffi (1.10.0)
19
+ formatador (0.2.5)
20
+ guard (2.15.0)
21
+ formatador (>= 0.2.4)
22
+ listen (>= 2.7, < 4.0)
23
+ lumberjack (>= 1.0.12, < 2.0)
24
+ nenv (~> 0.1)
25
+ notiffany (~> 0.0)
26
+ pry (>= 0.9.12)
27
+ shellany (~> 0.0)
28
+ thor (>= 0.18.1)
29
+ guard-bundler (2.2.0)
30
+ bundler (>= 1.3.0)
31
+ guard (~> 2.2)
32
+ guard-compat (~> 1.1)
33
+ guard-compat (1.2.1)
34
+ guard-rspec (4.7.3)
35
+ guard (~> 2.1)
36
+ guard-compat (~> 1.1)
37
+ rspec (>= 2.99.0, < 4.0)
38
+ json (2.1.0)
39
+ listen (3.1.5)
40
+ rb-fsevent (~> 0.9, >= 0.9.4)
41
+ rb-inotify (~> 0.9, >= 0.9.7)
42
+ ruby_dep (~> 1.2)
43
+ lumberjack (1.0.13)
44
+ method_source (0.9.2)
45
+ nenv (0.3.0)
46
+ notiffany (0.1.1)
47
+ nenv (~> 0.1)
48
+ shellany (~> 0.0)
49
+ pry (0.12.2)
50
+ coderay (~> 1.1.0)
51
+ method_source (~> 0.9.0)
52
+ rake (10.5.0)
53
+ rb-fsevent (0.10.3)
54
+ rb-inotify (0.10.0)
55
+ ffi (~> 1.0)
56
+ rspec (3.8.0)
57
+ rspec-core (~> 3.8.0)
58
+ rspec-expectations (~> 3.8.0)
59
+ rspec-mocks (~> 3.8.0)
60
+ rspec-core (3.8.0)
61
+ rspec-support (~> 3.8.0)
62
+ rspec-expectations (3.8.2)
63
+ diff-lcs (>= 1.2.0, < 2.0)
64
+ rspec-support (~> 3.8.0)
65
+ rspec-mocks (3.8.0)
66
+ diff-lcs (>= 1.2.0, < 2.0)
67
+ rspec-support (~> 3.8.0)
68
+ rspec-support (3.8.0)
69
+ ruby_dep (1.5.0)
70
+ shellany (0.0.1)
71
+ simplecov (0.16.1)
72
+ docile (~> 1.1)
73
+ json (>= 1.8, < 3)
74
+ simplecov-html (~> 0.10.0)
75
+ simplecov-html (0.10.2)
76
+ term-ansicolor (1.7.0)
77
+ tins (~> 1.0)
78
+ thor (0.19.4)
79
+ tins (1.20.2)
80
+ yard (0.9.16)
81
+
82
+ PLATFORMS
83
+ ruby
84
+
85
+ DEPENDENCIES
86
+ alu0100406580_nutricion!
87
+ bundler (~> 1.17)
88
+ coveralls
89
+ guard
90
+ guard-bundler
91
+ guard-rspec
92
+ rake (~> 10.0)
93
+ rspec (~> 3.0)
94
+ yard
95
+
96
+ BUNDLED WITH
97
+ 1.17.1
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Alu0100406580Nutricion
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/alu0100406580_nutricion`. 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 'alu0100406580_nutricion'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install alu0100406580_nutricion
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]/alu0100406580_nutricion.
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
@@ -0,0 +1,46 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "alu0100406580_nutricion/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "alu0100406580_nutricion"
8
+ spec.version = Alu0100406580Nutricion::VERSION
9
+ spec.authors = ["Dario Afonso"]
10
+ spec.email = ["alu0100406580@ull.edu.es"]
11
+
12
+ spec.summary = %q{TDD - Tabla nutricional}
13
+ spec.description = %q{Desarrollo Dirigido por Pruebas (TDD). Representación de un programa en Ruby para representar una Tabla Nutricional y más cosas.}
14
+ spec.homepage = "https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100406580"
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
+ =begin if spec.respond_to?(:metadata)
19
+ spec.metadata["allowed_push_host"] = "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
+ =end
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
+ spec.add_development_dependency "guard"
42
+ spec.add_development_dependency "guard-rspec"
43
+ spec.add_development_dependency "guard-bundler"
44
+ spec.add_development_dependency "yard"
45
+ spec.add_development_dependency "coveralls"
46
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "alu0100406580_nutricion"
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,40 @@
1
+ require "alu0100406580_nutricion/version"
2
+ require "alu0100406580_nutricion/version"
3
+ require "alu0100406580_nutricion/tabla"
4
+ require "alu0100406580_nutricion/listaDobleEnlazada"
5
+ require "alu0100406580_nutricion/paciente"
6
+ require "alu0100406580_nutricion/menuDSL"
7
+
8
+
9
+ module Nutricion
10
+ # Your code goes here...
11
+ end
12
+
13
+ module Lista
14
+ # Your code goes here...
15
+ end
16
+
17
+ module Obesidad
18
+ # Your code goes here...
19
+ end
20
+
21
+ module Funcional
22
+ # Your code goes here...
23
+ end
24
+
25
+ module MenuDSL
26
+ # Your code goes here...
27
+ end
28
+
29
+ module Menu
30
+ # Your code goes here...
31
+ end
32
+
33
+ module Modulos
34
+ # Your code goes here...
35
+ end
36
+
37
+ module Alu0100406580Nutricion
38
+ class Error < StandardError; end
39
+ # Your code goes here...
40
+ end
@@ -0,0 +1,120 @@
1
+ #
2
+ # @author Darío Afonso Rodríguez
3
+ # @abstract Struct Node
4
+
5
+ Node = Struct.new(:value, :next, :prev)
6
+
7
+ #
8
+ # == Clase ListaDobleEnlazada
9
+ # Clase para definir una lista doblemente enlazada.
10
+ # Contiene Enumerable y Comparable(Este no se usa)
11
+ # * initialize
12
+ # * insertinsertaAdelante
13
+ # * insertinsertaAtrás
14
+ # * extraerDelante
15
+ # * extraerDetrás
16
+ # * is_empty?
17
+ # * to_s
18
+ # * each
19
+ #
20
+
21
+ class ListaDobleEnlazada
22
+
23
+
24
+ include Enumerable
25
+ include Comparable
26
+
27
+ attr_accessor :cabeza, :cola, :tamaño
28
+ attr_reader :cabeza, :cola, :tamaño
29
+
30
+ def initialize()
31
+ @cabeza = nil
32
+ @cola = nil
33
+ @tamaño = 0
34
+ end
35
+
36
+ def insertaAdelante(valor)
37
+ nodo = Node.new(valor,nil,nil)
38
+
39
+ if (self.tamaño == 0)
40
+ @cabeza = nodo
41
+ @cola = nodo
42
+
43
+ else
44
+ nodo["next"] = @cabeza
45
+ @cabeza.prev = nodo
46
+ @cabeza = nodo
47
+ end
48
+ @tamaño = @tamaño + 1
49
+ end
50
+
51
+ def insertaAtras(valor)
52
+ nodo = Node.new(valor,nil,nil)
53
+
54
+ if (self.tamaño == 0)
55
+ @cabeza = nodo
56
+ @cola = nodo
57
+
58
+ else
59
+ nodo["prev"] = @cola
60
+ @cola.next = nodo
61
+ @cola = nodo
62
+ end
63
+ @tamaño = @tamaño + 1
64
+ end
65
+
66
+ def extraerDelante
67
+ if(self.tamaño == 0)
68
+ return "Lista Vacía"
69
+ else
70
+ nodoAux = @cabeza
71
+ @cabeza = @cabeza["next"]
72
+ @tamaño = @tamaño - 1
73
+ return nodoAux["value"]
74
+ end
75
+ end
76
+
77
+ def extraerDetras
78
+ if(self.tamaño == 0)
79
+ return "Lista Vacía"
80
+ else
81
+ nodoAux = @cola
82
+ @cola = @cola["prev"]
83
+ @tamaño = @tamaño - 1
84
+ return nodoAux["value"]
85
+ end
86
+ end
87
+
88
+ def is_empty?
89
+ return self.tamaño.zero?
90
+ end
91
+
92
+ def to_s
93
+ nodoAux = Node.new(nil,nil,nil)
94
+ nodoAux = @cabeza
95
+ arr = []
96
+ if (self.tamaño == 0)
97
+ return "Lista Vacía"
98
+ else
99
+ while(nodoAux != nil)
100
+ arr.push nodoAux["value"]
101
+ nodoAux = nodoAux["next"]
102
+ end
103
+ return arr
104
+ end
105
+ end
106
+
107
+
108
+
109
+ def <=>(other)
110
+ end
111
+
112
+ def each
113
+ nodoAux = Node.new(nil,nil,nil)
114
+ nodoAux = @cabeza
115
+ while(nodoAux != nil)
116
+ yield nodoAux["value"]
117
+ nodoAux = nodoAux["next"]
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,75 @@
1
+ class MenuFacil
2
+ def initialize(name, &block)
3
+ @nombre = name
4
+ @desayuno = []
5
+ @almuerzo = []
6
+ @cena = []
7
+
8
+ if block_given?
9
+ if block.arity == 1
10
+ yield self
11
+ else
12
+ instance_eval(&block)
13
+ end
14
+ end
15
+ end
16
+
17
+ def titulo(titulo)
18
+ @titulo = titulo
19
+ end
20
+
21
+ def ingesta(ingesta)
22
+ @ingesta = ingesta
23
+ end
24
+
25
+ def desayuno(opciones = {})
26
+ ingrediente = []
27
+ ingrediente << opciones[:descripcion] << opciones[:porcion] << opciones[:gramos] << Tabla.new(opciones[:grasas],opciones[:grasasSaturadas],opciones[:carbohidratos],opciones[:azucares],opciones[:proteinas],opciones[:sal])
28
+ @desayuno << ingrediente
29
+ end
30
+
31
+ def almuerzo(opciones = {})
32
+ ingrediente = []
33
+ ingrediente << opciones[:descripcion] << opciones[:porcion] << opciones[:gramos] << Tabla.new(opciones[:grasas],opciones[:grasasSaturadas],opciones[:carbohidratos],opciones[:azucares],opciones[:proteinas],opciones[:sal])
34
+ @almuerzo << ingrediente
35
+ end
36
+
37
+ def cena(opciones = {})
38
+ ingrediente = []
39
+ ingrediente << opciones[:descripcion] << opciones[:porcion] << opciones[:gramos] << Tabla.new(opciones[:grasas],opciones[:grasasSaturadas],opciones[:carbohidratos],opciones[:azucares],opciones[:proteinas],opciones[:sal])
40
+ @cena << ingrediente
41
+ end
42
+
43
+ def to_s
44
+ output = @nombre
45
+ output << " (#{@titulo}), Ingesta: #{@ingesta}"
46
+ output << "#{' ' * 50} Composición Nutricional #{' ' * 50}"
47
+ output << "\n#{'=' * 165}\n"
48
+ output << "#{' ' * 35} Porción Gramos #{' ' * 50} Grasas Grasas-saturadas Hidratos Azucares Proteinas Sal\n" #58 75 85 95 106 111
49
+ output << "Desayuno\n"
50
+ kcaltotal = 0
51
+ @desayuno.each_with_index do |instruction, i|
52
+ output << "\"#{instruction[0]}\" #{' ' * (31 - instruction[0].size.to_i)}#{instruction[1]}#{' ' * (15 - instruction[1].size.to_i)}#{instruction[2]}#{' ' * (64 - instruction[2].size.to_i)}#{instruction[3].grasas}#{' ' * 10}#{instruction[3].grasasSat}#{' ' * 12}#{instruction[3].hidratos}#{' ' * 3}#{instruction[3].azucares}#{' ' * 5}#{instruction[3].proteinas}#{' ' * 8}#{instruction[3].sal}\n"
53
+ kcaltotal += instruction[3].valEnerKcal
54
+ end
55
+ output << "\nValor Energetico total desayuno: #{kcaltotal.round(2)}Kcal\n"
56
+
57
+ output << "\nAlmuerzo\n"
58
+ kcaltotal = 0
59
+ @almuerzo.each_with_index do |instruction, i|
60
+ output << "\"#{instruction[0]}\" #{' ' * (31 - instruction[0].size.to_i)}#{instruction[1]}#{' ' * (15 - instruction[1].size.to_i)}#{instruction[2]}#{' ' * (64 - instruction[2].size.to_i)}#{instruction[3].grasas}#{' ' * 10}#{instruction[3].grasasSat}#{' ' * 12}#{instruction[3].hidratos}#{' ' * 3}#{instruction[3].azucares}#{' ' * 5}#{instruction[3].proteinas}#{' ' * 8}#{instruction[3].sal}\n"
61
+ kcaltotal += instruction[3].valEnerKcal
62
+ end
63
+ output << "\nValor Energetico total almuerzo: #{kcaltotal.round(2)}Kcal\n"
64
+
65
+ output << "\nCena\n"
66
+ kcaltotal = 0
67
+ @cena.each_with_index do |instruction, i|
68
+ output << "\"#{instruction[0]}\" #{' ' * (31 - instruction[0].size.to_i)}#{instruction[1]}#{' ' * (15 - instruction[1].size.to_i)}#{instruction[2]}#{' ' * (64 - instruction[2].size.to_i)}#{instruction[3].grasas}#{' ' * 10}#{instruction[3].grasasSat}#{' ' * 12}#{instruction[3].hidratos}#{' ' * 3}#{instruction[3].azucares}#{' ' * 5}#{instruction[3].proteinas}#{' ' * 8}#{instruction[3].sal}\n"
69
+ kcaltotal += instruction[3].valEnerKcal
70
+ end
71
+ output << "\nValor Energetico total cena: #{kcaltotal.round(2)}Kcal\n"
72
+ output
73
+
74
+ end
75
+ end
@@ -0,0 +1,169 @@
1
+ #
2
+ # @author Darío Afonso Rodríguez
3
+ # @abstract Clase Persona
4
+
5
+ #
6
+ # == Clase Persona
7
+ # Clase para definir una Persona siendo la clase padre de Paciente
8
+ # Contiene Enumerable(Este no se usa) y Comparable(Este no se usa)
9
+ # * initialize
10
+ #
11
+
12
+
13
+ class Persona
14
+
15
+ include Enumerable
16
+ include Comparable
17
+
18
+ attr_accessor :nombre, :apellidos, :edad, :genero
19
+
20
+ def initialize(nombre, apellidos, edad, genero)
21
+ @nombre = nombre
22
+ @apellidos = apellidos
23
+ @edad = edad
24
+ @genero = genero
25
+ end
26
+ end
27
+
28
+ #
29
+ # == Clase Paciente
30
+ # Clase para definir un Paciente que hereda de Persona
31
+ # Contiene Enumerable(Este no se usa) y Comparable
32
+ # * initialize
33
+ # * pliegues
34
+ # * to_s
35
+ # * imc
36
+ # * rcc
37
+ # * porcent_grasa
38
+ # * bicipital
39
+ # * tricipital
40
+ # * subescapular
41
+ # * suprailiaco
42
+ # * <=>
43
+ #
44
+
45
+ class Paciente < Persona
46
+
47
+ include Enumerable
48
+ include Comparable
49
+
50
+ attr_reader :nombre,:fecha,:edad,:talla,:factorActividad
51
+ attr_accessor :genero,:peso,:pc_bicipital,:pc_tricipital,:pc_subescapular,:pc_suprailiaco
52
+
53
+ def initialize(nombre,apellidos,edad, genero, peso, talla, factorActividad = 0)
54
+ super(@nombre = nombre, @apellidos = apellidos, @edad = edad, @genero = genero)
55
+ @peso, @talla, @factorActividad = peso, talla, factorActividad
56
+ end
57
+
58
+ def pliegues(pc_bicipital,pc_tricipital,pc_subescapular,pc_suprailiaco)
59
+ @pc_bicipital,@pc_tricipital,@pc_subescapular,@pc_suprailiaco = pc_bicipital,pc_tricipital,pc_subescapular,pc_suprailiaco
60
+ end
61
+
62
+ def to_s
63
+ return "{Nombre:#{@nombre}, Apellidos:#{@apellidos}, Edad:#{@edad}, Género:#{@genero}, Peso:#{@peso}, Talla:#{@talla}}"
64
+ end
65
+
66
+ def imc
67
+ return (@peso/(@talla*@talla)).round(2)
68
+ end
69
+
70
+ def rcc(cintura,cadera)
71
+ rcc = (cintura/cadera)
72
+ if ((@genero == 1 && rcc >= 0.83 && rcc <= 0.88) || (@genero == 0 && rcc >= 0.72 && rcc <= 0.75))
73
+ return "Riesgo Bajo RCC: #{rcc.round(2)}"
74
+ elsif ((@genero == 1 && rcc >= 0.88 && rcc <= 0.95) || (@genero == 0 && rcc >= 0.78 && rcc <= 0.82))
75
+ return "Riesgo Medio RCC: #{rcc.round(2)}"
76
+ elsif ((@genero == 1 && rcc >= 0.95 && rcc <= 1.01) || (@genero == 0 && rcc >= 0.82))
77
+ return "Riesgo Alto RCC: #{rcc.round(2)}"
78
+ elsif ((@genero == 1 && rcc >= 1.01))
79
+ return "Riesgo Muy Alto RCC: #{rcc.round(2)}"
80
+ else
81
+ return "fuera de rango o algún dato mal introducido"
82
+ end
83
+ end
84
+
85
+ def porcent_grasa
86
+ return (1.2*self.imc+0.23*@edad-10.8*@genero-5.4).round(3)
87
+ end
88
+
89
+ def bicipital()
90
+ bicipi = []
91
+ for i in 1..3
92
+ puts "Introduzca medida #{i} para pliegue Bicipital:"
93
+ j = gets.to_i
94
+ bicipi.push(j)
95
+ end
96
+ sum = bicipi.inject(0){ |sum, x| sum + x }
97
+ @pc_bicipital = (sum/bicipi.size.to_f).round(2)
98
+ return "El pliegue Bicipital medio es -> #{pc_bicipital}mm"
99
+ end
100
+
101
+ def tricipital()
102
+ tricipi = []
103
+ for i in 1..3
104
+ puts "Introduzca medida #{i} para pliegue tricipital:"
105
+ j = gets.to_i
106
+ tricipi.push(j)
107
+ end
108
+ sum = tricipi.inject(0){ |sum, x| sum + x }
109
+ @pc_tricipital = (sum/tricipi.size.to_f).round(2)
110
+ return "El pliegue Tricipital medio es -> #{pc_tricipital}mm"
111
+ end
112
+
113
+ def subescapular()
114
+ subesc = []
115
+ for i in 1..3
116
+ puts "Introduzca medida #{i} para pliegue Subescapular:"
117
+ j = gets.to_i
118
+ subesc.push(j)
119
+ end
120
+ sum = subesc.inject(0){ |sum, x| sum + x }
121
+ @pc_subescapular = (sum/subesc.size.to_f).round(2)
122
+ return "El pliegue Subescapular medio es -> #{pc_subescapular}mm"
123
+ end
124
+
125
+ def suprailiaco()
126
+ supraili = []
127
+ for i in 1..3
128
+ puts "Introduzca medida #{i} para pliegue Suprailiaco:"
129
+ j = gets.to_i
130
+ supraili.push(j)
131
+ end
132
+ sum = supraili.inject(0){ |sum, x| sum + x }
133
+ @pc_suprailiaco = (sum/supraili.size.to_f).round(2)
134
+ return "El pliegue Suprailiaco medio es -> #{pc_suprailiaco}mm"
135
+ end
136
+
137
+ def gastoEnergiaTotal()
138
+ #pesoTeorico = (@talla - 150) * 0.75 + 50
139
+ gastoEnerBasal = @genero == 1 ? (@peso * 10) + (6.25 * @talla) - (5 * @edad) + 5 : (@peso * 10) + (6.25 * @talla) - (5 * @edad) - 161
140
+ efectoTermogeno = (gastoEnerBasal * 0.10).round(2)
141
+ gastoActividadFisica = gastoEnerBasal * factorActividad
142
+ (gastoEnerBasal + efectoTermogeno + gastoActividadFisica).round(2)
143
+ end
144
+
145
+
146
+ def <=>(other)
147
+ return nil unless other.instance_of? Paciente
148
+ mayor = 0
149
+ menor = 0
150
+
151
+ mayor += 1 if self.peso > other.peso
152
+ mayor += 1 if self.talla > other.talla
153
+ mayor += 1 if self.imc > other.imc
154
+ mayor += 1 if self.porcent_grasa > other.porcent_grasa
155
+
156
+
157
+ menor += 1 if self.peso < other.peso
158
+ menor += 1 if self.talla < other.talla
159
+ menor += 1 if self.imc < other.imc
160
+ menor += 1 if self.porcent_grasa < other.porcent_grasa
161
+
162
+
163
+ return mayor <=> menor if ((mayor && menor) != 0)
164
+ return 0<=>0
165
+ end
166
+
167
+ def each
168
+ end
169
+ end
@@ -0,0 +1,123 @@
1
+ #
2
+ # == Clase Tabla
3
+ # Clase para definir una Tabla Nutricional
4
+ # Contiene Enumerable(Este no se usa) y Comparable
5
+ # * initialize
6
+ # * grasasMonoinsaturadas
7
+ # * grasasPoli
8
+ # * poliAlcoholes
9
+ # * almidon
10
+ # * vitaminas
11
+ # * minerales
12
+ # * to_s
13
+ # * porciones
14
+ # * ingesta
15
+ # * <=>
16
+ #
17
+
18
+ class Tabla
19
+
20
+ #
21
+ # @author Darío Afonso Rodríguez
22
+ # @abstract Clase Tabla Nutricional
23
+
24
+ include Enumerable
25
+ include Comparable
26
+
27
+ attr_reader :grasas, :grasasSat, :hidratos, :azucares, :proteinas, :sal, :valEnerKJ, :valEnerKcal
28
+ attr_accessor :grasasMonoinsaturadas, :grasasPoli, :poliAlcoholes, :almidon, :fibra, :vitaminas, :minerales
29
+
30
+ def initialize(grasas, grasasSat, hidratos, azucares, proteinas, sal)
31
+ @grasas, @grasasSat, @hidratos, @azucares, @proteinas, @sal = grasas, grasasSat, hidratos, azucares, proteinas, sal
32
+ @valEnerKJ = ((@grasas*37)+(@hidratos*17)+(@proteinas*17))
33
+ @valEnerKcal = ((@grasas*9)+(@hidratos*4)+(@proteinas*4))
34
+ @valEnerKJTotal = ((@grasas*37)+(@hidratos*17)+(@proteinas*17)+(@sal*25)+(grasasMonoinsaturadas*37)+(grasasPoli*37)+(poliAlcoholes*10)+(almidon*17)+(fibra*8))
35
+ @valEnerKcalTotal = ((@grasas*9)+(@hidratos*4)+(@proteinas*4)+(@sal*6)+(grasasMonoinsaturadas*9)+(grasasPoli*9)+(poliAlcoholes*2.4)+(almidon*4)+(fibra*2))
36
+ end
37
+
38
+ def grasasMonoinsaturadas
39
+ @grasasMonoinsaturadas ||= 0
40
+ end
41
+
42
+ def grasasPoli
43
+ @grasasPoli ||= 0
44
+ end
45
+
46
+ def poliAlcoholes
47
+ @poliAlcoholes ||= 0
48
+ end
49
+
50
+ def almidon
51
+ @almidon ||= 0
52
+ end
53
+
54
+ def fibra
55
+ @fibra ||= 0
56
+ end
57
+
58
+ def vitaminas
59
+ @vitaminas ||= 0
60
+ end
61
+
62
+ def minerales
63
+ @minerales ||= 0
64
+ end
65
+
66
+ def to_s
67
+ return "El valor energético: #{@valEnerKJ}KJ/#{@valEnerKcal}Kcal Cantidad de grasas: #{@grasas} Cantidad de grasas saturadas: #{@grasasSat} Hidratos de carbono: #{@hidratos} Azúcares: #{@azucares} Proteínas: #{@proteinas} Sal: #{@sal}"
68
+ end
69
+
70
+ def porciones(porcion)
71
+ valKJpor = ((@valEnerKJ * porcion) / 100)
72
+ valKCpor = ((@valEnerKcal * porcion) / 100)
73
+ grasaspor = ((@grasas * porcion) / 100)
74
+ grasasSatpor = ((@grasasSat * porcion) / 100)
75
+ hidratospor = ((@hidratos * porcion) / 100)
76
+ azucarespor = ((@azucares * porcion) / 100)
77
+ proteinaspor = ((@proteinas * porcion) / 100)
78
+ salpor = ((@sal * porcion) / 100)
79
+ return "cada porcion de #{porcion} tiene: Valor energetico:#{valKJpor}KJ/#{valKCpor}, grasas: #{grasaspor}, grasas saturadas: #{grasasSatpor}, hidratos de carbono: #{hidratospor}, azucares: #{azucarespor}, proteinas: #{proteinaspor}, sal: #{salpor}"
80
+ end
81
+
82
+ def ingesta
83
+ valKJing = ((@valEnerKJ * 100) / 8400)
84
+ valKCing = ((@valEnerKcal * 100) / 2000)
85
+ grasasing = ((@grasas * 100) / 70)
86
+ grasasSating = ((@grasasSat * 20) / 20)
87
+ hidratosing = ((@hidratos * 100) / 260)
88
+ azucaresing = ((@azucares * 100) / 90)
89
+ proteinasing = ((@proteinas * 100) / 50)
90
+ saling = ((@sal * 100) / 6)
91
+
92
+ return "Ingesta de referencia: Valor energético: #{valKJing}%KJ/#{valKCing}%Kcal, Grasa total: #{grasasing.round(2)}%, Ácidos grasos saturados: #{grasasSating}, Hidratos de carbono: #{hidratosing.round(2)}%, Azúcares: #{azucaresing}%, Proteínas: #{proteinasing}, Sal: #{saling.round(2)}"
93
+ end
94
+
95
+ def <=>(other)
96
+ return nil unless other.instance_of? Tabla
97
+ mayor = 0
98
+ menor = 0
99
+
100
+ mayor += 1 if self.grasas > other.grasas
101
+ mayor += 1 if self.grasasSat > other.grasasSat
102
+ mayor += 1 if self.hidratos > other.hidratos
103
+ mayor += 1 if self.azucares > other.azucares
104
+ mayor += 1 if self.proteinas > other.proteinas
105
+ mayor += 1 if self.sal > other.sal
106
+ mayor += 1 if self.valEnerKJ > other.valEnerKJ
107
+ mayor += 1 if self.valEnerKcal > other.valEnerKcal
108
+
109
+ menor += 1 if self.grasas < other.grasas
110
+ menor += 1 if self.grasasSat < other.grasasSat
111
+ menor += 1 if self.hidratos < other.hidratos
112
+ menor += 1 if self.azucares < other.azucares
113
+ menor += 1 if self.proteinas < other.proteinas
114
+ menor += 1 if self.sal < other.sal
115
+ menor += 1 if self.valEnerKJ < other.valEnerKJ
116
+ menor += 1 if self.valEnerKcal < other.valEnerKcal
117
+
118
+
119
+ return mayor <=> menor if ((mayor && menor) != 0)
120
+ return 0 <=> 0
121
+ end
122
+
123
+ end
@@ -0,0 +1,3 @@
1
+ module Alu0100406580Nutricion
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alu0100406580_nutricion
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dario Afonso
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-01-11 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: yard
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
+ - !ruby/object:Gem::Dependency
112
+ name: coveralls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Desarrollo Dirigido por Pruebas (TDD). Representación de un programa
126
+ en Ruby para representar una Tabla Nutricional y más cosas.
127
+ email:
128
+ - alu0100406580@ull.edu.es
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".rspec"
135
+ - ".travis.yml"
136
+ - Gemfile
137
+ - Gemfile.lock
138
+ - README.md
139
+ - Rakefile
140
+ - alu0100406580_nutricion.gemspec
141
+ - bin/console
142
+ - bin/setup
143
+ - lib/alu0100406580_nutricion.rb
144
+ - lib/alu0100406580_nutricion/listaDobleEnlazada.rb
145
+ - lib/alu0100406580_nutricion/menuDSL.rb
146
+ - lib/alu0100406580_nutricion/paciente.rb
147
+ - lib/alu0100406580_nutricion/tabla.rb
148
+ - lib/alu0100406580_nutricion/version.rb
149
+ homepage: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100406580
150
+ licenses: []
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.7.7
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: TDD - Tabla nutricional
172
+ test_files: []