alu0100882339menu 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dcf00419f6cbf95f74b145442aeeea70e000cc8d
4
+ data.tar.gz: 80a021b073e407a4da21ef5de2d529bc5fa2b15a
5
+ SHA512:
6
+ metadata.gz: a7ae03092c67a93935345b63ad9c94637e29c4b8f3b47b0b6852c5e6ab8f0a953f64ecd6cf8562b11a8cd39b97e4957ab9a89b52914bb43dcc82c831d5d2a9e6
7
+ data.tar.gz: dade53e930d80b73a1ef71d560d3e7bb12fa9145ead201ff14de674c12060d6ce3344eb1b8b3e78014bde080e8f01355c1898626b25f398f29c97d767fd0bab8
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.4
5
+ before_install: gem install bundler -v 1.15.4
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "Ein/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "alu0100882339menu"
8
+ spec.version = Ein::VERSION
9
+ spec.authors = ["alu0100882339"]
10
+ spec.email = ["alu0100882339@ull.edu.es"]
11
+
12
+ spec.summary = %q{"Gema de la práctica 6"}
13
+ spec.description = %q{"Gema de la práctica 6: Desarrollo Dirigido por Pruebas(TDD)"}
14
+ spec.homepage = "https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100882339.git"
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"] = "TODO: Set to 'http://mygemserver.com'"
20
+ #else
21
+ # raise "RubyGems 2.0 or newer is required to protect against " \
22
+ # "public gem pushes."
23
+ #end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.15"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rspec", "~> 3.0"
35
+ spec.add_development_dependency "guard"
36
+ spec.add_development_dependency "guard-rspec"
37
+ spec.add_development_dependency "guard-bundler"
38
+ spec.add_development_dependency "coveralls"
39
+ end
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 Ein.gemspec
6
+ gemspec
@@ -0,0 +1,83 @@
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
+
52
+ # Ruby files
53
+ ruby = dsl.ruby
54
+ dsl.watch_spec_files_for(ruby.lib_files)
55
+
56
+ # Rails files
57
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
58
+ dsl.watch_spec_files_for(rails.app_files)
59
+ dsl.watch_spec_files_for(rails.views)
60
+
61
+ watch(rails.controllers) do |m|
62
+ [
63
+ rspec.spec.call("routing/#{m[1]}_routing"),
64
+ rspec.spec.call("controllers/#{m[1]}_controller"),
65
+ rspec.spec.call("acceptance/#{m[1]}")
66
+ ]
67
+ end
68
+
69
+ # Rails config changes
70
+ watch(rails.spec_helper) { rspec.spec_dir }
71
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
72
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
73
+
74
+ # Capybara features specs
75
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
76
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
77
+
78
+ # Turnip features and steps
79
+ watch(%r{^spec/acceptance/(.+)\.feature$})
80
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
81
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
82
+ end
83
+ end
@@ -0,0 +1,37 @@
1
+ # Ein
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/Ein`. 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 'Ein'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install Ein
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]/Ein.
36
+
37
+ https://coveralls.io/repos/github/ULL-ESIT-LPP-1819/tdd-alu0100882339/badge.svg?branch=master(Coverage Status)!:https://coveralls.io/github/ULL-ESIT-LPP-1819/tdd-alu0100882339?branch=master
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "Ein"
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__)
@@ -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,11 @@
1
+ require "Ein/version"
2
+ require "Ein/p6"
3
+ require "Ein/p7"
4
+ require "Ein/individuo"
5
+ require "Ein/paciente"
6
+ require "Ein/menu"
7
+ require "benchmark"
8
+
9
+ module Ein
10
+ # Your code goes here...
11
+ end
@@ -0,0 +1,24 @@
1
+
2
+ class Individuo
3
+ attr_reader :nombre, :edad
4
+ include Comparable
5
+ def initialize(nombre, edad)
6
+
7
+ @nombre = nombre
8
+ @edad = edad
9
+ end
10
+
11
+ def <=> (other)
12
+
13
+ return nil unless other.instance_of?Individuo
14
+ edad <=> other.edad
15
+
16
+ end
17
+
18
+ def to_s
19
+
20
+ "#{@nombre}"
21
+
22
+
23
+ end
24
+ end
@@ -0,0 +1,207 @@
1
+ class Menu
2
+
3
+ attr_accessor :dia, :titulo, :ingestas, :desayunos, :almuerzos, :cenas
4
+
5
+
6
+ def initialize (dia, &block)
7
+
8
+ @dia = dia
9
+ @titulo = nil
10
+ @ingestas = []
11
+ @desayunos = []
12
+ @almuerzos = []
13
+ @cenas = []
14
+
15
+ if block_given?
16
+ if block.arity == 1
17
+ yield self
18
+ else
19
+ instance_eval(&block)
20
+ end
21
+ end
22
+
23
+ end
24
+
25
+
26
+
27
+ def titulo(tit)
28
+
29
+ @titulo = tit
30
+
31
+ end
32
+ def ingesta(ing, options = {})
33
+
34
+ ingesta = ing
35
+ ingesta << "(#{options[:min]})" if options[:min]
36
+ ingesta << "(#{options[:max]})" if options[:max]
37
+
38
+ @ingestas << ingesta
39
+
40
+
41
+ end
42
+
43
+ def desayuno (des, options = {})
44
+
45
+ desayuno = des
46
+ desyuno << "(#{options[:descripcion]})" if options[:descripcion]
47
+ desyuno << "(#{options[:porcion]})" if options[:porcion]
48
+ desyuno << "(#{options[:gramos]})" if options[:gramos]
49
+ desyuno << "(#{options[:grasas]})" if options[:grasas]
50
+ desyuno << "(#{options[:carbohidratos]})" if options[:carbohidratos]
51
+ desyuno << "(#{options[:proteinas]})" if options[:proteinas]
52
+ desyuno << "(#{options[:fibra]})" if options[:fibra]
53
+ desyuno << "(#{options[:sal]})" if options[:sal]
54
+
55
+ @desayunos << desayuno
56
+
57
+ end
58
+
59
+
60
+ def almuerzo (alm, options = {})
61
+
62
+ almuerzo = alm
63
+
64
+ almuerzo << "(#{options[:descripcion]})" if options[:descripcion]
65
+ almuerzo << "(#{options[:porcion]})" if options[:porcion]
66
+ almuerzo << "(#{options[:gramos]})" if options[:gramos]
67
+ almuerzo << "(#{options[:grasas]})" if options[:grasas]
68
+ almuerzo << "(#{options[:carbohidratos]})" if options[:carbohidratos]
69
+ almuerzo << "(#{options[:proteinas]})" if options[:proteinas]
70
+ almuerzo << "(#{options[:fibra]})" if options[:fibra]
71
+ almuerzo << "(#{options[:sal]})" if options[:sal]
72
+
73
+ @almuerzos << almuerzo
74
+
75
+ end
76
+
77
+
78
+ def cena (cen, options = {})
79
+
80
+ cena = cen
81
+
82
+ cena << "(#{options[:descripcion]})" if options[:descripcion]
83
+ cena << "(#{options[:porcion]})" if options[:porcion]
84
+ cena << "(#{options[:gramos]})" if options[:gramos]
85
+ cena << "(#{options[:grasas]})" if options[:grasas]
86
+ cena << "(#{options[:carbohidratos]})" if options[:carbohidratos]
87
+ cena << "(#{options[:proteinas]})" if options[:proteinas]
88
+ cena << "(#{options[:fibra]})" if options[:fibra]
89
+ cena << "(#{options[:sal]})" if options[:sal]
90
+
91
+ @cenas << cena
92
+
93
+
94
+ end
95
+
96
+
97
+
98
+
99
+ def to_s
100
+ #aqui tienes q cambiarlo por esto
101
+ #output = "\n #{@dia}" porq si no no te imprime el dia estaras escachando las cosas
102
+ @valor_total = 0
103
+ output = "\n#{@titulo}\n"
104
+ output << "#{@dia} \t\t Composición nutricional \n"
105
+
106
+ output << "========================================================\n"
107
+ output << "\t\t\tGrasas Carbohidratos Proteínas Fibra Sal Valor energético\n"
108
+ output << "Desayuno\n"
109
+ @desayunos.each do |desayuno|
110
+
111
+ if desayuno[:descripcion] == nil
112
+ desayuno[:descripcion] = "--"
113
+ end
114
+ if desayuno[:grasas] == nil
115
+ desayuno[:grasas] = 0.0
116
+ end
117
+ if desayuno[:carbohidratos] == nil
118
+ desayuno[:carbohidratos] = 0.0
119
+ end
120
+ if desayuno[:proteinas] == nil
121
+ desayuno[:proteinas] = 0.0
122
+ end
123
+ if desayuno[:fibra] == nil
124
+ desayuno[:fibra] = 0.0
125
+ end
126
+ if desayuno[:sal] == nil
127
+ desayuno[:sal] = 0.0
128
+ end
129
+ output << "#{desayuno[:descripcion]}\t"
130
+ output << "#{desayuno[:grasas]} "
131
+ output << "\t #{desayuno[:carbohidratos]} "
132
+ output << "\t#{desayuno[:proteinas]} "
133
+ output << "\t #{desayuno[:fibra]} "
134
+ output << "\t#{desayuno[:sal]} "
135
+ output << "\t#{@valor_e_kc_d = ((4.0 * desayuno[:carbohidratos]) + (4.0 * desayuno[:proteinas]) + (9.0 * desayuno[:grasas]) + (6.0 * desayuno[:sal])).round(2)}\n"
136
+ @valor_total += @valor_e_kc_d
137
+ end
138
+
139
+ output << "\n\nAlmuerzo\n"
140
+ @almuerzos.each do |almuerzo|
141
+ if almuerzo[:descripcion] == nil
142
+ almuerzo[:descripcion] = "--"
143
+ end
144
+ if almuerzo[:grasas] == nil
145
+ almuerzo[:grasas] = 0.0
146
+ end
147
+ if almuerzo[:carbohidratos] == nil
148
+ almuerzo[:carbohidratos] = 0.0
149
+ end
150
+ if almuerzo[:proteinas] == nil
151
+ almuerzo[:proteinas] = 0.0
152
+ end
153
+ if almuerzo[:fibra] == nil
154
+ almuerzo[:fibra] = 0.0
155
+ end
156
+ if almuerzo[:sal] == nil
157
+ almuerzo[:sal] = 0.0
158
+ end
159
+ output << "\n#{almuerzo[:descripcion]} "
160
+ output << " \t\t #{almuerzo[:grasas]} "
161
+ output << "\t #{almuerzo[:carbohidratos]} "
162
+ output << "\t#{almuerzo[:proteinas]} "
163
+ output << "\t #{almuerzo[:fibra]} "
164
+ output << "\t#{almuerzo[:sal]} "
165
+ output << "\t#{@valor_e_kc_a = ((4.0 * almuerzo[:carbohidratos]) + (4.0 * almuerzo[:proteinas]) + (9.0 * almuerzo[:grasas]) + (6.0 * almuerzo[:sal])).round(2)}"
166
+ @valor_total += @valor_e_kc_a
167
+
168
+ end
169
+
170
+
171
+
172
+ output << "\n\nCena\n"
173
+ @cenas.each do |cena|
174
+ if cena[:descripcion] == nil
175
+ cena[:descripcion] = "--"
176
+ end
177
+ if cena[:grasas] == nil
178
+ cena[:grasas] = 0.0
179
+ end
180
+ if cena[:carbohidratos] == nil
181
+ cena[:carbohidratos] = 0.0
182
+ end
183
+ if cena[:proteinas] == nil
184
+ cena[:proteinas] = 0.0
185
+ end
186
+ if cena[:fibra] == nil
187
+ cena[:fibra] = 0.0
188
+ end
189
+ if cena[:sal] == nil
190
+ cena[:sal] = 0.0
191
+ end
192
+ output << "\n#{cena[:descripcion]} "
193
+ output << " #{cena[:grasas]} "
194
+ output << "\t #{cena[:carbohidratos]} "
195
+ output << "\t#{cena[:proteinas]} "
196
+ output << "\t #{cena[:fibra]} "
197
+ output << "\t#{cena[:sal]} "
198
+ output << "\t#{@valor_e_kc_c = ((4.0 * cena[:carbohidratos]) + (4.0 * cena[:proteinas]) + (9.0 * cena[:grasas]) + (6.0 * cena[:sal])).round(2)}"
199
+ @valor_total += @valor_e_kc_c
200
+ #Tienes q devolver la variable
201
+ end
202
+ output << "\nValor energético total"
203
+ output << "\t#{@valor_total}"
204
+ output
205
+
206
+ end
207
+ end
@@ -0,0 +1,91 @@
1
+ class EIN
2
+ attr_reader :nombre, :grasa_t, :grasa_s, :hidratos_c, :azucares, :proteinas, :sal, :t_porciones, :porciones
3
+ include Comparable
4
+ def initialize(nombre, grasa_t, grasa_s, hidratos_c, azucares, proteinas, sal, t_porciones, porciones)
5
+
6
+ @nombre = nombre
7
+ @grasa_t = grasa_t
8
+ @grasa_s = grasa_s
9
+ @hidratos_c = hidratos_c
10
+ @azucares = azucares
11
+ @proteinas = proteinas
12
+ @sal = sal
13
+ @valor_e_kj = valor_e_kj
14
+ @valor_e_kc = valor_e_kc
15
+ @t_porciones = t_porciones
16
+ @porciones = porciones
17
+ @ingesta_recomendada = [8400.0, 2000.0, 70.0, 20.0, 260.0, 90.0, 50.0, 6.0]
18
+
19
+ end
20
+
21
+ def valor_e_kj
22
+
23
+ (17.0 * hidratos_c) + (17.0 * proteinas) + (37.0 * grasa_t) + (25.0 * sal)
24
+ end
25
+
26
+ def valor_e_kc
27
+
28
+ (4.0 * hidratos_c) + (4.0 * proteinas) + (9.0 * grasa_t) + (6.0 * sal)
29
+ end
30
+
31
+
32
+ def info
33
+
34
+
35
+ puts "Información nutricional de #{@nombre}"
36
+ puts "\t\t\t\t Por 100g ó 100ml de producto | IR (Por 100g/ml de producto) % | Por porción de #{@t_porciones}g/ml | IR por porción de #{@t_porciones}g/ml de producto %"
37
+ puts "Valor energético (kj/kcal) |\t\t#{@valor_e_kj}/#{@valor_e_kc}\t |\t\t #{((@valor_e_kj/@ingesta_recomendada[0])*100).round(2)} / #{((@valor_e_kc/@ingesta_recomendada[1])*100).round(2)}\t | #{(@t_porciones*@valor_e_kj)/100} / #{((@t_porciones*@valor_e_kc)/100).round(2)} |\t #{(@t_porciones*(@valor_e_kj/@ingesta_recomendada[0])).round(2)} / #{(@t_porciones*(@valor_e_kc/@ingesta_recomendada[1])).round(2)}"
38
+ puts "Grasas de las cuales: |\t\t#{@grasa_t} \t | \t #{((@grasa_t/@ingesta_recomendada[2])*100).round(2)}\t\t | #{(@t_porciones*@grasa_t)/100}\t |\t #{(@t_porciones*(@grasa_t/@ingesta_recomendada[2])).round(2)} "
39
+ puts " Saturadas |\t\t#{@grasa_s} \t | \t #{((@grasa_s/@ingesta_recomendada[3])*100).round(2)}\t\t | #{(@t_porciones*@grasa_s)/100}\t\t |\t #{(@t_porciones*(@grasa_s/@ingesta_recomendada[3])).round(2)} "
40
+ puts "Hidratos de carbono |\t\t#{@hidratos_c} \t\t | \t #{((@hidratos_c/@ingesta_recomendada[4])*100).round(2)}\t\t | #{(@t_porciones*@hidratos_c)/100}\t |\t #{(@t_porciones*(@hidratos_c/@ingesta_recomendada[4])).round(2)} "
41
+ puts "de lo cuales:"
42
+ puts " Azúcares |\t\t#{@azucares} \t | \t #{((@azucares/@ingesta_recomendada[5])*100).round(2)}\t\t | #{(@t_porciones*@azucares)/100}\t |\t #{(@t_porciones*(@azucares/@ingesta_recomendada[5])).round(2)} "
43
+ puts "Proteínas |\t\t#{@proteinas} \t | \t #{((@proteinas/@ingesta_recomendada[6])*100).round(2)}\t\t | #{(@t_porciones*@proteinas)/100}\t |\t #{(@t_porciones*(@proteinas/@ingesta_recomendada[6])).round(2)} "
44
+ puts "Sal |\t\t#{@sal} \t | \t #{((@sal/@ingesta_recomendada[7])*100).round(2)}\t\t | #{(@t_porciones*@sal)/100}\t\t |\t #{(@t_porciones*(@sal/@ingesta_recomendada[7])).round(2)} "
45
+
46
+ end
47
+
48
+ def clasificar_sal
49
+
50
+ if (sal <= 5.0)
51
+
52
+ "Nivel de sal bajo"
53
+
54
+ elsif (sal > 5.0 && sal <= 10.0)
55
+
56
+ "Nivel de sal normal"
57
+
58
+ elsif (sal > 10.0 && sal <= 50.0)
59
+
60
+ "Nivel de sal alto"
61
+ else
62
+
63
+ "Nivel de sal muy alto"
64
+ end
65
+
66
+ end
67
+
68
+ def <=> (other)
69
+
70
+
71
+ return nil unless other.instance_of?EIN
72
+ valor_e_kj <=> other.valor_e_kj
73
+
74
+ end
75
+
76
+
77
+ def to_s
78
+
79
+ "#{@nombre}"
80
+
81
+ end
82
+
83
+
84
+
85
+
86
+
87
+
88
+ end
89
+
90
+
91
+
@@ -0,0 +1,105 @@
1
+ Node = Struct.new(:value, :next, :prev)
2
+
3
+ class Lista
4
+ attr_accessor :head, :tail
5
+ include Enumerable
6
+
7
+ def initialize
8
+
9
+ @head = nil
10
+ @tail = nil
11
+
12
+ end
13
+
14
+ def set_head(value)
15
+ nodo = Node.new(value, nil, nil)
16
+
17
+ if(@head== nil)
18
+ @head = nodo
19
+ @tail = nodo
20
+
21
+ else
22
+
23
+ @head.prev = nodo
24
+ nodo.next = @head
25
+ @head = nodo
26
+ end
27
+
28
+
29
+
30
+ end
31
+
32
+ def set_tail(value)
33
+ nodo = Node.new(value, nil, nil)
34
+
35
+ if(@tail == nil)
36
+ @head = nodo
37
+ @tail = nodo
38
+ else
39
+
40
+ @tail.next = nodo
41
+ nodo.prev = @tail
42
+ @tail = nodo
43
+ end
44
+
45
+ end
46
+
47
+ def get_head
48
+
49
+ aux = @head
50
+ @head = @head.next
51
+ #@head.prev = nil
52
+ #aux.next = nil
53
+ aux
54
+
55
+
56
+ end
57
+
58
+ def get_tail
59
+
60
+ aux = @tail
61
+ @tail = @tail.prev
62
+ # @tail.next = nil
63
+ # aux.prev = nil
64
+ aux
65
+ end
66
+
67
+ def empty?
68
+
69
+ @head == nil
70
+ @tail == nil
71
+
72
+ end
73
+
74
+ def clasificar_lista_sal
75
+
76
+ while(empty? != true) do
77
+ puts get_tail.value.clasificar_sal
78
+
79
+ end
80
+ true
81
+ end
82
+
83
+
84
+ def each
85
+
86
+ it = @head
87
+
88
+ while it != nil
89
+
90
+ yield it.value
91
+ it = it.next
92
+ end
93
+
94
+
95
+ end
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+ end
@@ -0,0 +1,97 @@
1
+
2
+
3
+ class Paciente < Individuo
4
+ attr_reader :peso, :talla, :sexo, :peso_teorico_ideal, :gasto_e_basal, :efecto_t
5
+
6
+ def initialize(nombre, edad, peso, talla, sexo)
7
+ super(nombre, edad)
8
+ @peso = peso
9
+ @talla = talla
10
+ @sexo = sexo
11
+ @peso_teorico_ideal = calcular_peso_ideal
12
+ @gasto_e_basal = calcular_gasto_e_basal
13
+ @efecto_t = calcular_efecto_t
14
+
15
+ end
16
+
17
+
18
+ def calcular_imc
19
+
20
+ ( @peso/(@talla*@talla)).round(2)
21
+
22
+ end
23
+
24
+ def calcular_peso_ideal
25
+
26
+ talla_i = @talla * 100
27
+
28
+ ((talla_i - 150) * 0.75 + 50).round(2)
29
+ end
30
+
31
+ def calcular_gasto_e_basal
32
+ talla_i = @talla * 100
33
+ if(@sexo == "Mujer")
34
+ ((10*@peso)+(6.25*talla_i) - (5*@edad) - 161).round(2)
35
+ else
36
+ ((10*@peso)+(6.25*talla_i) - (5*@edad) - 5).round(2)
37
+ end
38
+
39
+ end
40
+
41
+ def calcular_efecto_t
42
+
43
+ (@gasto_e_basal * 0.10).round(2)
44
+
45
+ end
46
+
47
+ def gasto_a_fisica(actividad)
48
+
49
+ if(actividad == "Reposo")
50
+ (@gasto_e_basal * 0.0).round(2)
51
+ elsif(actividad == "Actividad ligera")
52
+ (@gasto_e_basal * 0.12).round(2)
53
+ elsif (actividad == "Actividad moderada")
54
+ (@gasto_e_basal * 0.27).round(2)
55
+ elsif (actividad == "Actividad intensa")
56
+ (@gasto_e_basal * 0.54).round(2)
57
+ end
58
+
59
+ end
60
+
61
+ def gasto_e_total(actividad)
62
+
63
+ ( @gasto_e_basal + @efecto_t + gasto_a_fisica(actividad)).round(2)
64
+ end
65
+
66
+ def clasificar_imc
67
+ imc = calcular_imc
68
+
69
+ if(imc < 18.5)
70
+ "Bajo peso -- Delgado"
71
+ elsif(imc >= 18.5 && imc <= 24.9)
72
+ "Adecuado -- Aceptable"
73
+ elsif(imc >= 25 && imc <=29.9)
74
+ "Sobrepeso -- Sobrepeso"
75
+ elsif(imc >= 30 && imc <= 34.9)
76
+ "Obesidad grado 1 -- Obesidad"
77
+ elsif(imc >= 35 && imc <= 39.9)
78
+ "Obesidad grado 2 -- Obesidad"
79
+ elsif(imc >= 40)
80
+ "Obesidad grado 3 -- Obesidad"
81
+ end
82
+ end
83
+
84
+ def to_s
85
+ puts "------------------------------------------------------------------------------- \n"
86
+ puts "\t Nombre: #{@nombre}"
87
+ puts "\t Edad: #{@edad}"
88
+ puts "\t Sexo: #{@sexo}"
89
+ puts "\t Peso: #{@peso}"
90
+ puts "\t Talla: #{@talla}"
91
+ puts "\t Resultado de su imc: #{clasificar_imc}"
92
+ puts "------------------------------------------------------------------------------- \n"
93
+
94
+ end
95
+
96
+
97
+ end
@@ -0,0 +1,3 @@
1
+ module Ein
2
+ VERSION = "0.1.4"
3
+ end
File without changes
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alu0100882339menu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ platform: ruby
6
+ authors:
7
+ - alu0100882339
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.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
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: '"Gema de la práctica 6: Desarrollo Dirigido por Pruebas(TDD)"'
112
+ email:
113
+ - alu0100882339@ull.edu.es
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".coveralls.yml"
119
+ - ".gitignore"
120
+ - ".travis.yml"
121
+ - Ein.gemspec
122
+ - Gemfile
123
+ - Guardfile
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - lib/Ein.rb
129
+ - lib/Ein/individuo.rb
130
+ - lib/Ein/menu.rb
131
+ - lib/Ein/p6.rb
132
+ - lib/Ein/p7.rb
133
+ - lib/Ein/paciente.rb
134
+ - lib/Ein/version.rb
135
+ - travis.yml
136
+ homepage: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100882339.git
137
+ licenses: []
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubyforge_project:
155
+ rubygems_version: 2.6.11
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: '"Gema de la práctica 6"'
159
+ test_files: []