alu0100987522 0.1.0

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: bafe8cd1e1b057598c8dc14756ae4902985caf70
4
+ data.tar.gz: ae33198be1e000075ed6de5c2d87b7f5d3a1a55e
5
+ SHA512:
6
+ metadata.gz: 640f04e665ddb7afb1a8f2bc9894211456f595abef7a05d5d0481225ba9f97d34f4bf995213754f037a19e97fcfa5269b1012f6c58267a2c47e2c35f12de1eb9
7
+ data.tar.gz: a0da8c21d4d55ddc90163a98cf160bb01cdc46e898b8f280114f542d14758ebb2d137b84cd709207f7ca163d40a4c2f6af14d2289c93189e589d6fe5656e6ca0
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -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
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.4.0
7
+ before_install: gem install bundler -v 1.17.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at aitortin_@hotmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
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 gema.gemspec
6
+ gemspec
@@ -0,0 +1,113 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ alu0100987522 (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
+ yard (0.9.16)
97
+
98
+ PLATFORMS
99
+ ruby
100
+
101
+ DEPENDENCIES
102
+ alu0100987522!
103
+ bundler (~> 1.17)
104
+ coveralls
105
+ guard
106
+ guard-bundler
107
+ guard-rspec
108
+ rake (~> 10.0)
109
+ rspec (~> 3.0)
110
+ yard (~> 0.9.2)
111
+
112
+ BUNDLED WITH
113
+ 1.17.2
@@ -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
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Aitor Hernández
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ # Gema
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/gema`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'gema'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install gema
22
+
23
+ ## Usage
24
+
25
+ Use rake or execute guard in another terminal to test the code.
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]/gema. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Gema project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/gema/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,10 @@
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
+ task :p12 do
9
+ sh 'bundle exec rspec spec/p12_spec.rb'
10
+ end
@@ -0,0 +1,47 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "alu0100987522/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "alu0100987522"
8
+ spec.version = Alu0100987522::VERSION
9
+ spec.authors = ["Aitor Hernández"]
10
+ spec.email = ["alu0100987522@ull.edu.es"]
11
+
12
+ spec.summary = %q{gema de prácticas LPP}
13
+ spec.description = %q{gema para usar en las prácticas de LPP}
14
+ spec.homepage = "https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100987522-practica08"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = "https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100987522-practica08"
24
+ spec.metadata["changelog_uri"] = "https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100987522-practica08"
25
+ else
26
+ raise "RubyGems 2.0 or newer is required to protect against " \
27
+ "public gem pushes."
28
+ end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_development_dependency "bundler", "~> 1.17"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "rspec", "~> 3.0"
42
+ spec.add_development_dependency "guard"
43
+ spec.add_development_dependency "guard-rspec"
44
+ spec.add_development_dependency "guard-bundler"
45
+ spec.add_development_dependency "yard", "~> 0.9.2"
46
+ spec.add_development_dependency "coveralls"
47
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "gema"
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,5 @@
1
+ require "alu0100987522/version"
2
+ require "alu0100987522/etiqueta"
3
+ require "alu0100987522/lista"
4
+ require "alu0100987522/individuo"
5
+ require "alu0100987522/menu"
@@ -0,0 +1,32 @@
1
+ class Etiqueta
2
+
3
+ include Comparable
4
+
5
+ attr_reader :nombre, :grasas, :gsat, :carbh, :azucar, :protein, :sal
6
+
7
+
8
+ def initialize(nombre, grasas, gsat, carbh, azucar, protein, sal)
9
+
10
+ @nombre = nombre
11
+ @grasas = grasas
12
+ @gsat = gsat
13
+ @carbh = carbh
14
+ @azucar = azucar
15
+ @protein = protein
16
+ @sal = sal
17
+
18
+ end
19
+
20
+ def val_energetico
21
+ (grasas*9+carbh*4+protein*4)
22
+ end
23
+
24
+ def to_s
25
+ return %Q"#{@nombre} --- Grasas: #{@grasas} ; Saturadas: #{@gsat} -- Hidratos de Carbono: #{@carbh} -- Azucar: #{@azucar} -- Proteínas: #{@protein} -- Sal: #{@sal}. "
26
+ end
27
+
28
+ def <=>(another)
29
+ val_energetico <=> another.val_energetico
30
+ end
31
+
32
+ end
@@ -0,0 +1,88 @@
1
+ class Persona
2
+
3
+ attr_reader :nombre, :apellido, :edad, :genero
4
+
5
+ def initialize(nombre, apellido, edad, genero)
6
+ @nombre = nombre
7
+ @apellido = apellido
8
+ @edad = edad
9
+ @genero = genero
10
+ end
11
+
12
+ def to_s
13
+ return %Q(#{@nombre} #{@apellido} - Edad: #{@edad} años - Género: #{@genero}.)
14
+ end
15
+
16
+
17
+ end
18
+
19
+
20
+ class Paciente < Persona
21
+
22
+ include Comparable
23
+
24
+ attr_reader :peso, :talla, :actfis
25
+
26
+ def initialize(nombre, apellido, edad, genero, peso, talla, actfis)
27
+ super(nombre, apellido, edad, genero)
28
+ @peso = peso
29
+ @talla = talla
30
+ @actfis = actfis
31
+ @genero = genero
32
+ @edad = edad
33
+ end
34
+
35
+ def imc_calculo
36
+ return @peso/(@talla*@talla)
37
+ end
38
+
39
+ def imc_clasificar
40
+ imc = imc_calculo()
41
+ tipo = "";
42
+ if (imc<18.5)
43
+ tipo = "Delgado"
44
+ elsif(imc.between?(18.5, 24.9))
45
+ tipo = "Aceptable"
46
+ elsif(imc.between?(25.0, 29.9))
47
+ tipo = "Sobrepeso"
48
+ elsif (imc>29.9)
49
+ tipo = "Obesidad"
50
+ else
51
+ return "Error clasificando el imc: #{imc}."
52
+ end
53
+
54
+ return tipo
55
+ end
56
+
57
+ def to_s
58
+ return %Q(#{@nombre} #{@apellido} - Edad: #{@edad} años - Género: #{@genero} - Peso: #{@peso} kg - Talla: #{@talla} m - Factor act. física: #{@actfis}.)
59
+ end
60
+
61
+ def <=>(another)
62
+ imc_calculo <=> another.imc_calculo
63
+ end
64
+
65
+ def gasto_energetico_basal
66
+ geb = 0
67
+ if genero == "Masculino"
68
+ geb = 10.0*peso + 6.25*talla - 5.0*edad + 5
69
+ end
70
+ if genero == "Femenino"
71
+ geb = 10.0*peso + 6.25*talla - 5.0*edad - 161
72
+ end
73
+ return geb
74
+ end
75
+
76
+ def efecto_termogeno
77
+ gasto_energetico_basal() * 0.10
78
+ end
79
+
80
+ def gasto_actividad_fisica
81
+ gasto_energetico_basal() * actfis
82
+ end
83
+
84
+ def gasto_energetico_total
85
+ gasto_energetico_basal() + efecto_termogeno() + gasto_actividad_fisica()
86
+ end
87
+
88
+ end
@@ -0,0 +1,95 @@
1
+ class Lista
2
+
3
+ include Enumerable
4
+
5
+ attr_reader :head, :tail
6
+
7
+ Node = Struct.new(:value, :next, :prev)
8
+
9
+ def push_head(value)
10
+
11
+ if(@head == nil)
12
+ @head = Node.new(value, nil, nil)
13
+ @tail = head
14
+ else
15
+ nodo = Node.new(value, nil, @head)
16
+ @head.next = nodo
17
+ @head = nodo
18
+ end
19
+
20
+ end
21
+
22
+ def push_tail(value)
23
+
24
+ if(@tail == nil)
25
+ @tail = Node.new(value, nil, nil)
26
+ @head = tail
27
+ else
28
+ nodo = Node.new(value, @tail, nil)
29
+ @tail.prev = nodo
30
+ @tail = nodo
31
+ end
32
+ end
33
+
34
+ def pop_head()
35
+
36
+ if(@head == nil)
37
+ return nil
38
+ else
39
+ aux = @head.value
40
+ if(@head == @tail)
41
+ @head = @head.prev
42
+ @head, @tail = nil
43
+ else
44
+ @head = @head.prev
45
+ @head.next = nil
46
+ end
47
+ return aux
48
+ end
49
+ end
50
+
51
+ def pop_tail()
52
+
53
+ if(@tail == nil)
54
+ return nil
55
+ else
56
+ aux = @tail.value
57
+ if(@head == @tail)
58
+ @tail = @tail.next
59
+ @head, @tail = nil
60
+ else
61
+ @tail = @tail.next
62
+ @tail.prev = nil
63
+ end
64
+ return aux
65
+ end
66
+ end
67
+
68
+ def clasificar
69
+ if(@head.value.sal >= 5)
70
+ return true
71
+ else
72
+ return false
73
+ end
74
+ end
75
+
76
+ def to_s
77
+ str = @tail.value.to_s()
78
+ aux = @tail.next
79
+ while(aux)
80
+ str << aux.value.to_s()
81
+ aux = aux.next
82
+ end
83
+ return str
84
+ end
85
+
86
+ def each
87
+ x = @tail
88
+ while(x != nil)
89
+ yield x.value
90
+ x = x.next
91
+ end
92
+ end
93
+
94
+
95
+ end
@@ -0,0 +1,107 @@
1
+ class Menu
2
+
3
+ attr_reader :dia, :titulo, :ingesta, :desayuno, :almuerzo, :cena
4
+
5
+ def initialize(nombre, &block)
6
+ @nombre = nombre
7
+ @ingesta = []
8
+ @desayuno = []
9
+ @almuerzo = []
10
+ @cena = []
11
+
12
+ if block_given?
13
+ if block.arity == 1
14
+ yield self
15
+ else
16
+ instance_eval(&block)
17
+ end
18
+ end
19
+ end
20
+
21
+ def to_s
22
+ output = @nombre
23
+ output << "\t\t \"#{@titulo}\""
24
+ output << "\n#{'=' * 50 }\n"
25
+ output << "\nTiempo estimado de ingesta: #{@ingesta.join(' -')} minutos.\n"
26
+
27
+ output << "- Desayuno:\n"
28
+ @desayuno.each_with_index do |alimento, index|
29
+ output << "#{index+1}) #{alimento}\n"
30
+ end
31
+
32
+ output << "\n- Almuerzo:\n"
33
+ @almuerzo.each_with_index do |alimento, index|
34
+ output << "#{index+1}) #{alimento}\n"
35
+ end
36
+
37
+ output << "\n- Cena:\n"
38
+ @cena.each_with_index do |alimento, index|
39
+ output << "#{index+1}) #{alimento}\n"
40
+ end
41
+
42
+ output << "\n Valor energético total del menú: #{total_ve}\n"
43
+
44
+ output
45
+ end
46
+
47
+ def titulo(text)
48
+ @titulo = text
49
+ end
50
+
51
+ def ingesta(intervalo = {})
52
+ @ingesta << " (#{intervalo[:min]})" if intervalo[:min]
53
+ @ingesta << " (#{intervalo[:max]})" if intervalo[:max]
54
+ end
55
+
56
+ def desayuno(alimento, composicion = {})
57
+ grasas = composicion[:grasas] if composicion[:grasas]
58
+ gsat = composicion[:gsat] if composicion[:gsat]
59
+ carbh = composicion[:carbh] if composicion[:carbh]
60
+ azucar = composicion[:azucar] if composicion[:azucar]
61
+ protein = composicion[:protein] if composicion[:protein]
62
+ sal = composicion[:sal] if composicion[:sal]
63
+
64
+ @desayuno << Etiqueta.new(alimento, grasas, gsat, carbh, azucar, protein, sal)
65
+
66
+ end
67
+
68
+ def almuerzo(alimento, composicion = {})
69
+ grasas = composicion[:grasas] if composicion[:grasas]
70
+ gsat = composicion[:gsat] if composicion[:gsat]
71
+ carbh = composicion[:carbh] if composicion[:carbh]
72
+ azucar = composicion[:azucar] if composicion[:azucar]
73
+ protein = composicion[:protein] if composicion[:protein]
74
+ sal = composicion[:sal] if composicion[:sal]
75
+
76
+ @almuerzo << Etiqueta.new(alimento, grasas, gsat, carbh, azucar, protein, sal)
77
+
78
+ end
79
+
80
+ def cena(alimento, composicion = {})
81
+ grasas = composicion[:grasas] if composicion[:grasas]
82
+ gsat = composicion[:gsat] if composicion[:gsat]
83
+ carbh = composicion[:carbh] if composicion[:carbh]
84
+ azucar = composicion[:azucar] if composicion[:azucar]
85
+ protein = composicion[:protein] if composicion[:protein]
86
+ sal = composicion[:sal] if composicion[:sal]
87
+
88
+ @cena << Etiqueta.new(alimento, grasas, gsat, carbh, azucar, protein, sal)
89
+
90
+ end
91
+
92
+
93
+ def total_ve
94
+
95
+ all = 0.0
96
+ all += @desayuno.map { |ali| ali.val_energetico }.reduce(:+)
97
+ all += @almuerzo.map { |ali| ali.val_energetico }.reduce(:+)
98
+ all += @cena.map { |ali| ali.val_energetico }.reduce(:+)
99
+
100
+ return all.round(3)
101
+
102
+ end
103
+
104
+
105
+ end
106
+
107
+
@@ -0,0 +1,11 @@
1
+ module Alu0100987522
2
+ VERSION = "0.1.0"
3
+ end
4
+
5
+ class Etiqueta
6
+ VERSION = "0.1.0"
7
+ end
8
+
9
+ class Lista
10
+ VERSION = "0.1.0"
11
+ end
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alu0100987522
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Aitor Hernández
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.9.2
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.9.2
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: gema para usar en las prácticas de LPP
126
+ email:
127
+ - alu0100987522@ull.edu.es
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".coveralls.yml"
133
+ - ".gitignore"
134
+ - ".travis.yml"
135
+ - CODE_OF_CONDUCT.md
136
+ - Gemfile
137
+ - Gemfile.lock
138
+ - Guardfile
139
+ - LICENSE.txt
140
+ - README.md
141
+ - Rakefile
142
+ - alu0100987522.gemspec
143
+ - bin/console
144
+ - bin/setup
145
+ - lib/alu0100987522.rb
146
+ - lib/alu0100987522/etiqueta.rb
147
+ - lib/alu0100987522/individuo.rb
148
+ - lib/alu0100987522/lista.rb
149
+ - lib/alu0100987522/menu.rb
150
+ - lib/alu0100987522/version.rb
151
+ homepage: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100987522-practica08
152
+ licenses:
153
+ - MIT
154
+ metadata:
155
+ allowed_push_host: https://rubygems.org
156
+ homepage_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100987522-practica08
157
+ source_code_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100987522-practica08
158
+ changelog_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100987522-practica08
159
+ post_install_message:
160
+ rdoc_options: []
161
+ require_paths:
162
+ - lib
163
+ required_ruby_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ required_rubygems_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ requirements: []
174
+ rubyforge_project:
175
+ rubygems_version: 2.6.8
176
+ signing_key:
177
+ specification_version: 4
178
+ summary: gema de prácticas LPP
179
+ test_files: []