miriamrguez 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
+ SHA256:
3
+ metadata.gz: e7bebe77f8a5a5f359387393a510bc36617fd32eb936bdf8de0a7efbfec19677
4
+ data.tar.gz: bd5b650620db53be16691e9a0c583d4113b7a42ac2f42c633b4bcfae5a9de61b
5
+ SHA512:
6
+ metadata.gz: 26c94e4275b148a4dd2b6775f6f59c4f300b037338c29483acf4c490302983aa390f896b3f04b2c977a0595e590c8a3698f118be501f1b019837fea31221beda
7
+ data.tar.gz: 8d01f37b095415de15a611c5f77c501b9e799a9aada37581f8df5b01cd65ea88952a79a8ddd1832c0dbe35a829fda9000136c06bb4073ed0aaa6cbddd5a58d0b
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/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ before_install: gem install bundler -v 1.16.2
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 prct06.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,111 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ miriamrguez (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.5.0)
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.16)
102
+ coveralls
103
+ guard
104
+ guard-bundler
105
+ guard-rspec
106
+ miriamrguez!
107
+ rake (~> 10.0)
108
+ rspec (~> 3.0)
109
+
110
+ BUNDLED WITH
111
+ 1.16.2
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/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Prct06
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/prct06`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Esta es una gema de ejemplo
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'prct06'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install prct06
22
+
23
+ ## Usage
24
+
25
+ TODO: Representar etiqueta de información nutricional
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]/prct06.
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 "prct06"
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
data/lib/prct06.rb ADDED
@@ -0,0 +1,11 @@
1
+ require "prct06/version"
2
+ require "prct06/nutricion"
3
+ require "prct06/lista"
4
+ require "prct06/individuo"
5
+ require "prct06/paciente"
6
+ require "prct06/array"
7
+ require "prct06/menu.rb"
8
+
9
+ module Prct06
10
+ # Your code goes here...
11
+ end
@@ -0,0 +1,32 @@
1
+ class Array
2
+
3
+ def buclesfor
4
+ swapped = true
5
+ for i in 0 ...(self.length-1)
6
+ swapped = false
7
+ for j in 0 ... (self.length-i-1)
8
+ if self[j] > self[j+1]
9
+ self[j] , self[j+1] = self[j+1], self[j]
10
+ swapped = true
11
+ end
12
+ end
13
+ break if swapped == false
14
+ end
15
+ return self
16
+ end
17
+
18
+ def ordenar_each
19
+ swapped = true
20
+ self.each_index do |first|
21
+ swapped = false
22
+ self.each_index do |second|
23
+ if self[first] < self[second]
24
+ self[first], self[second] = self[second], self[first]
25
+ swapped = true
26
+ end
27
+ end
28
+ break if swapped == false
29
+ end
30
+ return self
31
+ end
32
+ end
@@ -0,0 +1,23 @@
1
+ # @author Miriam Rodríguez Méndez
2
+ # Esta clase representa un individuo
3
+ class Individuo
4
+ include Enumerable
5
+
6
+ # Permite el acceso a las variables
7
+ attr_accessor :edad, :nombre, :apellidos, :sexo, :peso
8
+
9
+ def initialize(edad,nombre,apellidos,sexo,peso)
10
+ @edad = edad
11
+ @nombre = nombre
12
+ @apellidos = apellidos
13
+ @sexo = sexo
14
+ @peso = peso
15
+ end
16
+
17
+ # Formatea los datos en un string
18
+ def to_s
19
+ "Edad: #{@edad} -- Nombre: #{@nombre} -- Apellidos: #{@apellidos} -- Sexo: #{@sexo} -- Peso: #{@peso}"
20
+ end
21
+
22
+
23
+ end
@@ -0,0 +1,122 @@
1
+ Node = Struct.new(:value, :next, :prev)
2
+
3
+ # @author Miriam Rodríguez Méndez
4
+ # Esta clase representa una lista doblemente enlazada
5
+ class Lista
6
+
7
+ #Esto permite la lectura de la cola y la cabeza de la lista
8
+ attr_reader :head, :tail
9
+ attr_accessor :node
10
+
11
+ include Enumerable
12
+ include Comparable
13
+
14
+ def initialize
15
+ @head = nil
16
+ @tail = nil
17
+ end
18
+
19
+ # Comprueba si la lista está vacía
20
+ #
21
+ # @return [bool] false si no está vacía, true si está vacía
22
+ def empty?
23
+ return (head == nil) && (tail == nil)
24
+ end
25
+
26
+ # Inserta un nodo por la cola
27
+ #
28
+ # @param value Cualquier objeto que se use como valor
29
+ def insert_tail(value)
30
+ if(empty?)
31
+ @head = Node.new(value,nil,nil)
32
+ @tail = @head
33
+ else
34
+ @tail[:next] = Node.new(value,nil,@tail)
35
+ @tail = @tail[:next]
36
+ end
37
+ end
38
+
39
+ # Extrae un nodo por la cabeza de la lista
40
+ #
41
+ # @return Devuelve el primer nodo de la lista
42
+ def extract_head
43
+ aux = @head.value
44
+ if(@head == @tail)
45
+ @head,@tail = nil
46
+ else
47
+ @head = @head[:next]
48
+ @head[:prev] = nil
49
+ end
50
+ return aux
51
+ end
52
+
53
+ # Convierte a un string la lista
54
+ def to_s
55
+ string = "("
56
+ aux = @head
57
+ while(aux != nil) do
58
+ string += "#{aux.to_s}"
59
+ @aux = @aux.next
60
+ end
61
+ string += ")"
62
+ return string
63
+ end
64
+
65
+ # Método para que la clase sea Enumerable
66
+ def each
67
+ aux = @head
68
+ while aux != nil do
69
+ yield aux.value
70
+ aux = aux.next
71
+ end
72
+ end
73
+
74
+ def sz
75
+ cont = 0
76
+ aux = @head
77
+ while(aux != nil) do
78
+ cont = cont + 1
79
+ aux=aux.next
80
+ end
81
+ return cont
82
+ end
83
+
84
+ def to_array_for
85
+ arr = []
86
+ aux = @head
87
+ for i in self do
88
+ arr.push(aux.value)
89
+ aux = aux.next
90
+ end
91
+ arr.buclesfor
92
+ end
93
+
94
+ def to_array_each
95
+ arr = []
96
+ aux = @head
97
+ for i in self do
98
+ arr.push(aux.value)
99
+ aux = aux.next
100
+ end
101
+ arr.ordenar_each
102
+ end
103
+
104
+
105
+ #def ordenar_for
106
+ # swapped = true
107
+ #aux = []
108
+ #for i in self
109
+ # swapped = false
110
+ #for j in self
111
+ #if j > i
112
+ #j = j+1
113
+ #j+1 = j
114
+ # swapped = true
115
+ # aux.push(i)
116
+ #end
117
+ #end
118
+ # break if swapped == false
119
+ #end
120
+ #return aux
121
+ #end
122
+ end
@@ -0,0 +1,132 @@
1
+ class Menu
2
+ attr_accessor :dia, :nombre, :ingesta, :descripcion
3
+
4
+ def initialize(dia,&block)
5
+ @dia = dia
6
+ @ingesta = []
7
+ @desayuno = []
8
+ @cena = []
9
+ @almuerzo = []
10
+
11
+ if block_given?
12
+ if block.arity == 1
13
+ yield self
14
+ else
15
+ instance_eval(&block)
16
+ end
17
+ end
18
+ end
19
+
20
+ def to_s
21
+ vet = 0
22
+ output = @dia
23
+ output << " Composición Nutricional\n"
24
+ output << "===========================================================\n"
25
+ output << " grasas carbohidratos proteínas fibra sal valor energético\n"
26
+ output << "Desayuno\n"
27
+ @desayuno.each do |alimento|
28
+ vet += valor_energetico(alimento)
29
+ output << "*#{alimento[:descripcion]}* "
30
+ output << "#{alimento[:grasas]} "
31
+ output << "#{alimento[:carbohidratos]} "
32
+ output << "#{alimento[:proteinas]} "
33
+ output << "#{alimento[:fibra]} "
34
+ output << "#{alimento[:sal]} "
35
+ output << "#{valor_energetico(alimento)}\n"
36
+
37
+ end
38
+
39
+ output << "\nAlmuerzo\n"
40
+ @almuerzo.each do |alimento|
41
+ vet += valor_energetico(alimento)
42
+ output << "*#{alimento[:descripcion]}* "
43
+ output << "#{alimento[:grasas]} "
44
+ output << "#{alimento[:carbohidratos]} "
45
+ output << "#{alimento[:proteinas]} "
46
+ output << "#{alimento[:fibra]} "
47
+ output << "#{alimento[:sal]} "
48
+ output << "#{valor_energetico(alimento)}\n"
49
+
50
+ end
51
+
52
+ output << "\nCena\n"
53
+ @cena.each do |alimento|
54
+ vet += valor_energetico(alimento)
55
+ output << "*#{alimento[:descripcion]}* "
56
+ output << "#{alimento[:grasas]} "
57
+ output << "#{alimento[:carbohidratos]} "
58
+ output << "#{alimento[:proteinas]} "
59
+ output << "#{alimento[:fibra]} "
60
+ output << "#{alimento[:sal]} "
61
+ output << "#{valor_energetico(alimento)}\n"
62
+
63
+ end
64
+
65
+ output << "Valor energético total "
66
+ output << "#{vet}"
67
+
68
+
69
+ output
70
+ end
71
+
72
+ def valor_energetico(comida)
73
+ kcal = comida[:grasas] * 0.9
74
+ kcal += comida[:carbohidratos] * 0.4
75
+ kcal += comida[:proteinas] * 0.4
76
+ kcal.round(2)
77
+ end
78
+
79
+ def titulo(nom)
80
+ nombr = nom
81
+ end
82
+
83
+ def ingesta(ing, options = {})
84
+ ingest = ing
85
+ ingest << "(#{options[:min]})" if options[:min]
86
+ ingest << "(#{options[:max]})" if options[:max]
87
+
88
+ @ingesta << ingest
89
+ end
90
+
91
+ def desayuno(des, options = {})
92
+ bf = des
93
+ bf << "(#{options[:descripcion]})" if options[:descripcion]
94
+ bf << "(#{options[:porcion]})" if options[:porcion]
95
+ bf << "(#{options[:gramos]})" if options[:gramos]
96
+ bf << "(#{options[:grasas]})" if options[:grasas]
97
+ bf << "(#{options[:carbohidratos]})" if options[:carbohidratos]
98
+ bf << "(#{options[:proteinas]})" if options[:proteinas]
99
+ bf << "(#{options[:fibra]})" if options[:fibra]
100
+ bf << "(#{options[:sal]})" if options[:sal]
101
+
102
+ @desayuno << bf
103
+ end
104
+
105
+ def almuerzo(al, options = {})
106
+ lunch = al
107
+ lunch << "(#{options[:descripcion]})" if options[:descripcion]
108
+ lunch << "(#{options[:porcion]})" if options[:porcion]
109
+ lunch << "(#{options[:gramos]})" if options[:gramos]
110
+ lunch << "(#{options[:grasas]})" if options[:grasas]
111
+ lunch << "(#{options[:carbohidratos]})" if options[:carbohidratos]
112
+ lunch << "(#{options[:proteinas]})" if options[:proteinas]
113
+ lunch << "(#{options[:fibra]})" if options[:fibra]
114
+ lunch << "(#{options[:sal]})" if options[:sal]
115
+
116
+ @almuerzo << lunch
117
+ end
118
+
119
+ def cena(ce, options = {})
120
+ din = ce
121
+ din << "(#{options[:descripcion]})" if options[:descripcion]
122
+ din << "(#{options[:porcion]})" if options[:porcion]
123
+ din << "(#{options[:gramos]})" if options[:gramos]
124
+ din << "(#{options[:grasas]})" if options[:grasas]
125
+ din << "(#{options[:carbohidratos]})" if options[:carbohidratos]
126
+ din << "(#{options[:proteinas]})" if options[:proteinas]
127
+ din << "(#{options[:fibra]})" if options[:fibra]
128
+ din << "(#{options[:sal]})" if options[:sal]
129
+
130
+ @cena << din
131
+ end
132
+ end
@@ -0,0 +1,239 @@
1
+ # @author Miriam Rodríguez Méndez
2
+ # Esta clase representa la etiqueta nutricional de un alimento
3
+ class Etiqueta
4
+
5
+ include Comparable
6
+
7
+ #Permite la lectura y acceso de estas variables
8
+ attr_accessor :alimento, :grasas, :saturadas, :mono, :poli, :hidratos, :azucares,
9
+ :polial, :almidon, :fibra, :proteinas, :sal, :vitaminas
10
+
11
+ def initialize(alimento, grasas, saturadas, mono, poli, hidratos, azucares,
12
+ polial, almidon, fibra, proteinas, sal, vitaminas)
13
+
14
+ @alimento = alimento
15
+ @grasas = grasas
16
+ @saturadas = saturadas
17
+ @mono = mono
18
+ @poli = poli
19
+ @hidratos = hidratos
20
+ @azucares = azucares
21
+ @polial = polial
22
+ @almidon = almidon
23
+ @fibra = fibra
24
+ @proteinas = proteinas
25
+ @sal = sal
26
+ @vitaminas = vitaminas
27
+ end
28
+
29
+ #Calcula el valor energético en KJ
30
+ def valorEnergeticoKJ
31
+ kj = ((grasas.to_f * 37) + (saturadas.to_f * 37) + (mono.to_f * 37) + (poli.to_f * 37) + (hidratos.to_f * 17) + (azucares.to_f * 17) + (polial.to_f * 10) + (almidon.to_f * 17) + (fibra.to_f * 8) + (proteinas.to_f * 17) + (sal.to_f * 25)).round(2)
32
+
33
+ kj.round(2)
34
+ end
35
+
36
+ #Calcula el valor energético en Kcal
37
+ def valorEnergeticoKcal
38
+ kcal = ((grasas.to_f * 9) + (saturadas.to_f * 9) + (mono.to_f * 9) + (poli.to_f * 9) + (hidratos.to_f * 4) + (azucares.to_f * 4) + (polial.to_f * 2.4) + (almidon.to_f * 4) + (fibra.to_f * 2) + (proteinas.to_f * 4) + (sal.to_f * 6))
39
+
40
+ kcal.round(2)
41
+ end
42
+
43
+ #Calcula el IR de la grasa a partir de una etiqueta
44
+ def grasaIR
45
+ ((valorEnergeticoKJ.to_f*70)/8400).round(2)
46
+ end
47
+
48
+ #Calcula el IR de las grasas saturadas
49
+ def saturadasIR
50
+ ((valorEnergeticoKJ.to_f*20)/8400).round(2)
51
+ end
52
+
53
+ #Calcula el IR de los hidratos
54
+ def hidratosIR
55
+ ((valorEnergeticoKJ.to_f*260)/8400).round(2)
56
+ end
57
+
58
+ #Calcula el IR de los azucares
59
+ def azucaresIR
60
+ ((valorEnergeticoKJ.to_f*90)/8400).round(2)
61
+ end
62
+
63
+ #Calcula el IR de la cantidad de proteinas
64
+ def proteinasIR
65
+ ((valorEnergeticoKJ.to_f*50)/8400).round(2)
66
+ end
67
+
68
+ #Calcula el IR de los gramos de sal
69
+ def salIR
70
+ ((valorEnergeticoKJ.to_f*6)/8400).round(2)
71
+ end
72
+
73
+ #Calcula el IR de las vitaminas
74
+ def vitaminasIR
75
+ ((valorEnergeticoKJ.to_f*260)/8400).round(2)
76
+ end
77
+
78
+ #Calcula el valor energético por porción KJ
79
+ def valorEKJporcion
80
+ ((valorEnergeticoKJ.to_f*25)/100).round(2)
81
+ end
82
+
83
+ #Calcula el valor energético por porción en Kcal
84
+ def valorEKcalporcion
85
+ ((valorEnergeticoKcal.to_f*25)/100).round(2)
86
+ end
87
+
88
+ #Calcula las grasas por porción
89
+ def grasasporcion
90
+ ((grasas.to_f*25)/100).round(2)
91
+ end
92
+
93
+ #Calcula las grasas saturadas por porción
94
+ def saturadasporcion
95
+ ((saturadas.to_f*25)/100).round(2)
96
+ end
97
+
98
+ #Calcula las grasas monoinsaturadas por porción
99
+ def monoporcion
100
+ ((mono.to_f*25)/100).round(2)
101
+ end
102
+
103
+ #Calcula las grasas polinsaturadas por porción
104
+ def poliporcion
105
+ ((poli.to_f*25)/100).round(2)
106
+ end
107
+
108
+ #Calcula los hidratos por porción
109
+ def hidratosporcion
110
+ ((hidratos.to_f*25)/100).round(2)
111
+ end
112
+
113
+ #Calcula los azúcares por porción
114
+ def azucaresporcion
115
+ ((azucares.to_f*25)/100).round(2)
116
+ end
117
+
118
+ #Calcula los polialcoholes por porción
119
+ def polialcoholporcion
120
+ ((polial.to_f*25)/100).round(2)
121
+ end
122
+
123
+ #Calcula el almidón por porción
124
+ def almidonporcion
125
+ ((almidon.to_f*25)/100).round(2)
126
+ end
127
+
128
+ #Calcula la fibra por porción
129
+ def fibrasporcion
130
+ ((fibra.to_f*25)/100).round(2)
131
+ end
132
+
133
+ #Calcula las proteinas por porción
134
+ def proteinasporcion
135
+ ((proteinas.to_f*25)/100).round(2)
136
+ end
137
+
138
+ #Calcula la sal por porción
139
+ def salporcion
140
+ ((sal.to_f*25)/100).round(2)
141
+ end
142
+
143
+ #Calcula las vitaminas por porción
144
+ def vitaminasporcion
145
+ ((vitaminas.to_f*25)/100).round(2)
146
+ end
147
+
148
+ #Calcula el IR de las grasas por porción
149
+ def grasasIRporcion
150
+ ((grasaIR.to_f*25)/100).round(2)
151
+ end
152
+
153
+ #Calcula el IR de las saturadas por porción
154
+ def saturadasIRporcion
155
+ ((saturadasIR.to_f*25)/100).round(2)
156
+ end
157
+
158
+ #Calcula el IR de los hidratos por porción
159
+ def hidratosIRporcion
160
+ ((hidratosIR.to_f*25)/100).round(2)
161
+ end
162
+
163
+ #Calcula el IR de los azúcares por porción
164
+ def azucaresIRporcion
165
+ ((azucaresIR.to_f*25)/100).round(2)
166
+ end
167
+
168
+ #Calcula el IR de las proteinas por porción
169
+ def proteinasIRporcion
170
+ ((proteinasIR.to_f*25)/100).round(2)
171
+ end
172
+
173
+ #Calcula el IR de la sal por porción
174
+ def salIRporcion
175
+ ((salIR.to_f*25)/100).round(2)
176
+ end
177
+
178
+ #Calcula el IR de las vitamincas en porción
179
+ def vitaminasIRporcion
180
+ ((vitaminasIR.to_f*25)/100).round(2)
181
+ end
182
+
183
+ #Método para transformar en string las dos primeras columnas
184
+ def to_s2col
185
+ "Por 100 g o 100 ml de producto | IR (por 100 g o 100 ml de producto) |\n " +
186
+ "Valor energético (kj/kcal) | " +
187
+ "#{valorEnergeticoKJ}/#{valorEnergeticoKcal} | #{valorEnergeticoKJ}% |\n" +
188
+ "Grasas de las cuales: | #{grasas} | #{grasaIR}%\n" +
189
+ "Saturadas | #{saturadas} | #{saturadasIR} |\n" +
190
+ "Monoinsaturadas | #{mono} | - |\n" +
191
+ "Poliinsaturadas | #{poli} | - |\n" +
192
+ "Hidratos de carbono de los cuales: #{hidratos} | #{hidratosIR} |\n" +
193
+ "Azucares | #{azucares} | #{azucaresIR}\n" +
194
+ "Polialcoholes | #{polial} | - |\n" +
195
+ "Almidón | #{almidon} | - |\n" +
196
+ "Fibra alimentaria | #{fibra} | - |\n" +
197
+ "Proteinas | #{proteinas} | #{proteinasIR} |\n" +
198
+ "Sal | #{sal} | #{salIR} |\n" +
199
+ "Vitaminas/mineral | #{vitaminas} |\n"
200
+ end
201
+
202
+ #Método para transformar los datos en string
203
+ def to_sentera
204
+ "Por 100 g o 100 ml de producto | IR (por 100 g o 100 ml de producto) | " +
205
+ "Por porción de 25 g | IR (por porción de 25 g de producto) |\n" +
206
+ " Valor energético (kj/kcal) | " +
207
+ "#{valorEnergeticoKJ}/#{valorEnergeticoKcal} | #{valorEnergeticoKJ}% |" +
208
+ " #{valorEKJporcion} | #{valorEKcalporcion}\n" +
209
+ "Grasas de las cuales: | #{grasas} | #{grasaIR}% | #{grasasporcion} | " +
210
+ "#{grasasIRporcion}\n" +
211
+ "Saturadas | #{saturadas} | #{saturadasIR}% | #{saturadasporcion} | " +
212
+ "#{saturadasIRporcion}\n" +
213
+ "Monoinsaturadas | #{mono} | - | #{monoporcion} | - |\n" +
214
+ "Poliinsaturadas | #{poli} | - | #{poliporcion} | - |\n" +
215
+ "Hidratos de carbono de los cuales: #{hidratos} | #{hidratosIR} | " +
216
+ "#{hidratosporcion} | #{hidratosIRporcion} |\n" +
217
+ "Azucares | #{azucares} | #{azucaresIR} | #{azucaresporcion} | #{azucaresIRporcion} |" +
218
+ "Polialcoholes | #{polial} | - | #{polialcoholporcion} | - |\n" +
219
+ "Almidón | #{almidon} | - | #{almidonporcion} | - |\n" +
220
+ "Fibra alimentaria | #{fibra} | - | #{fibrasporcion} | - |\n" +
221
+ "Proteinas | #{proteinas} | #{proteinasIR} | #{proteinasporcion} | " +
222
+ "#{proteinasIRporcion} |\n" +
223
+ "Sal | #{sal} | #{salIR} | #{salporcion} | #{salIRporcion} |\n" +
224
+ "Vitaminas/mineral | #{vitaminas} | #{vitaminasIR} | #{vitaminasporcion} | " +
225
+ "#{vitaminasIRporcion} |"
226
+ end
227
+
228
+ # Operador <=> para el modulo Comparable
229
+ #
230
+ # @param aux [Etiqueta] Objeto de tipo etiqueta
231
+ # @return [bool] -1 menor, 0 igual, 1 mayor
232
+ def <=>(aux)
233
+ return self.valorEnergeticoKcal <=> aux.valorEnergeticoKcal
234
+ end
235
+
236
+ def +(other)
237
+ self.valorEnergeticoKcal.round(2) + other.valorEnergeticoKcal.round(2)
238
+ end
239
+ end
@@ -0,0 +1,175 @@
1
+ # @author Miriam Rodríguez Méndez
2
+ # Clase hija de individuo que representa datos de un paciente
3
+ class Paciente < Individuo
4
+
5
+ include Comparable
6
+
7
+ # Permite acceder a las variables
8
+ attr_accessor :edad, :sexo, :peso, :talla, :circun_cintu, :circun_cadera, :factor_actividad_fisica
9
+
10
+ def initialize (nombre, apellidos, edad, sexo, peso, talla, circun_cintu, circun_cadera, factor_actividad_fisica)
11
+ super(edad,nombre,apellidos,sexo,peso)
12
+ @talla = talla
13
+ @circun_cintu = circun_cintu
14
+ @circun_cadera = circun_cadera
15
+ @factor_actividad_fisica = factor_actividad_fisica
16
+ end
17
+
18
+ # Calcula el IMC teniendo en cuenta el peso y la altura
19
+ #
20
+ # @return [float] Valor del IMC
21
+ def imc
22
+ num = (@peso/(@talla*@talla)).round(2)
23
+ if num < 18.5
24
+ num #- Bajo peso"
25
+ elsif num > 18.5 and num < 24.9
26
+ num #- Adecuado"
27
+ elsif num > 25.0 and num < 29.9
28
+ num #- Sobrepeso"
29
+ elsif num > 30.0 and num < 34.9
30
+ num #Obesidad grado 1"
31
+ elsif num > 35.0 and num < 39.9
32
+ num #- Obesidad grado 2"
33
+ elsif num > 40
34
+ num #- Obesidad grado 2"
35
+ end
36
+ end
37
+
38
+ # Calcula la cantidad de grasa
39
+ #
40
+ # @return [float] Valor de la grasa
41
+ def grasa
42
+ 1.2*imc+0.23*@edad-10.8*@sexo-5.4
43
+ end
44
+
45
+ # Calcula la relación cintura cadera
46
+ #
47
+ # @return [float] Valor de RCC dependiendo del sexo
48
+ def rcc
49
+ number = (@circun_cintu.to_f/@circun_cadera.to_f).round(2)
50
+ if @sexo == 0
51
+ if number > 0.72 and number < 0.75
52
+ "(#{number})" #- riesgo bajo"
53
+ elsif number > 0.75 and number < 0.82
54
+ "(#{number})" #- riesgo moderado"
55
+ elsif number > 0.82
56
+ "(#{number})" #- riesgo alto"
57
+ end
58
+ elsif @sexo == 1
59
+ if number > 0.83 and number < 0.88
60
+ "(#{number})" #- riesgo bajo"
61
+ elsif number > 0.88 and number < 0.95
62
+ "(#{number})" #- riesgo moderado"
63
+ elsif number > 0.95 and number < 1.01
64
+ "(#{number})" #- riesgo alto"
65
+ elsif number > 1.01
66
+ "(#{number})" #- riesgo muy alto"
67
+ end
68
+ end
69
+
70
+ end
71
+
72
+ # Calcula el tamaño del pliegue tricipital
73
+ #
74
+ # @return [float] Valor del pliegue tricipital
75
+ def tricipital
76
+ media = 0.0
77
+ pliegue = [254,667,335]
78
+
79
+ 3.times do |i|
80
+ media += pliegue[i]
81
+ end
82
+
83
+ media /= 3
84
+ "(#{media.round(2)})"
85
+
86
+ end
87
+
88
+ # Calcula el tamaño del pliegue bicipital
89
+ #
90
+ # @return [float] Valor del pliegue bicipital
91
+ def bicipital
92
+ media2 = 0.0
93
+ pliegue2 = [158,332,200]
94
+
95
+ 3.times do |i|
96
+ media2 += pliegue2[i]
97
+ end
98
+
99
+ media2 /= 3
100
+ "(#{media2.round(2)})"
101
+ end
102
+
103
+ # Calcula el tamaño del pliegue subescapular
104
+ #
105
+ # @return [float] Valor del pliegue subescapular
106
+ def subescapular
107
+ media3 = 0.0
108
+ pliegue3 = [866,541,263]
109
+
110
+ 3.times do |i|
111
+ media3 += pliegue3[i]
112
+ end
113
+
114
+ media3 /= 3
115
+ "(#{media3.round(2)})"
116
+ end
117
+
118
+ # Calcula el tamaño del pliegue suprailiaco
119
+ #
120
+ # @return [float] Valor del pliegue suprailiaco
121
+ def suprailiaco
122
+ media4 = 0.0
123
+ pliegue4 = [45,89,220]
124
+
125
+ 3.times do |i|
126
+ media4 += pliegue4[i]
127
+ end
128
+
129
+ media4 /= 3
130
+ "(#{media4.round(2)})"
131
+ end
132
+
133
+ # Convierte los valores en un string
134
+ def to_s
135
+ super().to_s +
136
+ " -- Talla: #{@talla} -- Circunferencia Cintura: #{@circun_cintu} -- Circunferencia Cadera: #{@circun_cadera}"
137
+ end
138
+
139
+ # Método para poder usar Comparable
140
+ #
141
+ # @param aux [Paciente] Objeto de tipo paciente
142
+ # @return [bool] -1 menor,0 igual, 1 mayor
143
+ def <=>(aux)
144
+ self.imc <=> aux.imc
145
+ end
146
+
147
+ def peso_teorico_ideal
148
+ return (@talla-150)*0.75+50
149
+ end
150
+
151
+ def gasto_energetico_basal
152
+ if(sexo == 0)
153
+ return (10*@peso)+(6.25*talla)-(5*@edad)-161
154
+ elsif(sexo == 1)
155
+ return (10*@peso)+(6.25*talla)-(5*@edad)+5
156
+ end
157
+ end
158
+
159
+ def efecto_termogeno
160
+ return gasto_energetico_basal*0.10
161
+ end
162
+
163
+ def gasto_actividad_fisica
164
+ return gasto_energetico_basal*@factor_actividad_fisica
165
+ end
166
+
167
+ def gasto_energetico_total
168
+ return gasto_energetico_basal+efecto_termogeno+gasto_actividad_fisica
169
+ end
170
+
171
+ def <=>(other)
172
+ self.gasto_energetico_total <=> other.gasto_energetico_total
173
+ end
174
+
175
+ end
@@ -0,0 +1,3 @@
1
+ module Prct06
2
+ VERSION = "0.1.0"
3
+ end
data/prct06.gemspec ADDED
@@ -0,0 +1,42 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "prct06/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "miriamrguez"
8
+ spec.version = Prct06::VERSION
9
+ spec.authors = ["alu0100785050"]
10
+ spec.email = ["alu0100785050@ull.edu.es"]
11
+
12
+ spec.summary = %q{Ejemplo de gema}
13
+ spec.description = %q{Esta gema no hace nada}
14
+ spec.homepage = "https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100785050"
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://github.com/ULL-ESIT-LPP-1819/tdd-alu0100785050"
20
+ #else
21
+ # raise "RubyGems 2.0 or newer is required to protect against " \
22
+ # "public gem pushes."
23
+ #end
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_development_dependency "bundler", "~> 1.16"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "rspec", "~> 3.0"
37
+
38
+ spec.add_development_dependency "guard"
39
+ spec.add_development_dependency "guard-rspec"
40
+ spec.add_development_dependency "guard-bundler"
41
+ spec.add_development_dependency "coveralls"
42
+ end
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: miriamrguez
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - alu0100785050
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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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: Esta gema no hace nada
112
+ email:
113
+ - alu0100785050@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
+ - README.md
126
+ - Rakefile
127
+ - bin/console
128
+ - bin/setup
129
+ - doc/Etiqueta.html
130
+ - doc/Individuo.html
131
+ - doc/Lista.html
132
+ - doc/Node.html
133
+ - doc/Paciente.html
134
+ - doc/Prct06.html
135
+ - doc/_index.html
136
+ - doc/class_list.html
137
+ - doc/css/common.css
138
+ - doc/css/full_list.css
139
+ - doc/css/style.css
140
+ - doc/file.README.html
141
+ - doc/file_list.html
142
+ - doc/frames.html
143
+ - doc/index.html
144
+ - doc/js/app.js
145
+ - doc/js/full_list.js
146
+ - doc/js/jquery.js
147
+ - doc/method_list.html
148
+ - doc/top-level-namespace.html
149
+ - lib/prct06.rb
150
+ - lib/prct06/array.rb
151
+ - lib/prct06/individuo.rb
152
+ - lib/prct06/lista.rb
153
+ - lib/prct06/menu.rb
154
+ - lib/prct06/nutricion.rb
155
+ - lib/prct06/paciente.rb
156
+ - lib/prct06/version.rb
157
+ - prct06.gemspec
158
+ homepage: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100785050
159
+ licenses: []
160
+ metadata: {}
161
+ post_install_message:
162
+ rdoc_options: []
163
+ require_paths:
164
+ - lib
165
+ required_ruby_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ requirements: []
176
+ rubyforge_project:
177
+ rubygems_version: 2.7.7
178
+ signing_key:
179
+ specification_version: 4
180
+ summary: Ejemplo de gema
181
+ test_files: []