prct6lpp 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 02f0bab8cbbcdc422bd590fe93acd45893b00503
4
+ data.tar.gz: c69ab1d5518ecb447edeb04ccfac3fb2559052e3
5
+ SHA512:
6
+ metadata.gz: b5e7e67590e4bb68eb338fcaad966ef6636d9c4c52c0b8c0a9f449ea01faa770902ea9abbb2c83f49a91a234de98e9a04b7ac22b388359cf596304d2f5dc2399
7
+ data.tar.gz: 535018e570ee5d47b4bf478b9660cb6e31d9c907ef39ec4c8d9b78e522ac53f30eae5e489d1825aef75a3e4111fc56e7e11a636f935c85878da0550b5f9ed1ac
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.13.6
@@ -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 alu0100894325@ull.edu.es. 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,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in prct06.gemspec
4
+ gemspec
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.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ guard :bundler do
19
+ require 'guard/bundler'
20
+ require 'guard/bundler/verify'
21
+ helper = Guard::Bundler::Verify.new
22
+
23
+ files = ['Gemfile']
24
+ files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
25
+
26
+ # Assume files are symlinked from somewhere
27
+ files.each { |file| watch(helper.real_path(file)) }
28
+ end
29
+
30
+ # Note: The cmd option is now required due to the increasing number of ways
31
+ # rspec may be run, below are examples of the most common uses.
32
+ # * bundler: 'bundle exec rspec'
33
+ # * bundler binstubs: 'bin/rspec'
34
+ # * spring: 'bin/rspec' (This will use spring if running and you have
35
+ # installed the spring binstubs per the docs)
36
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
37
+ # * 'just' rspec: 'rspec'
38
+
39
+ guard :rspec, cmd: "bundle exec rspec" do
40
+ require "guard/rspec/dsl"
41
+ dsl = Guard::RSpec::Dsl.new(self)
42
+
43
+ # Feel free to open issues for suggestions and improvements
44
+
45
+ # RSpec files
46
+ rspec = dsl.rspec
47
+ watch(rspec.spec_helper) { rspec.spec_dir }
48
+ watch(rspec.spec_support) { rspec.spec_dir }
49
+ watch(rspec.spec_files)
50
+
51
+ # Ruby files
52
+ ruby = dsl.ruby
53
+ dsl.watch_spec_files_for(ruby.lib_files)
54
+
55
+ # Rails files
56
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
57
+ dsl.watch_spec_files_for(rails.app_files)
58
+ dsl.watch_spec_files_for(rails.views)
59
+
60
+ watch(rails.controllers) do |m|
61
+ [
62
+ rspec.spec.call("routing/#{m[1]}_routing"),
63
+ rspec.spec.call("controllers/#{m[1]}_controller"),
64
+ rspec.spec.call("acceptance/#{m[1]}")
65
+ ]
66
+ end
67
+
68
+ # Rails config changes
69
+ watch(rails.spec_helper) { rspec.spec_dir }
70
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
71
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
72
+
73
+ # Capybara features specs
74
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
75
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
76
+
77
+ # Turnip features and steps
78
+ watch(%r{^spec/acceptance/(.+)\.feature$})
79
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
80
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
81
+ end
82
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Fernando
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Prct06
2
+
3
+ Clase Dieta para la práctica de laboratorio 6.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'prct06'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install prct06
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ 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.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/prct06. 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.
34
+
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
39
+
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :menu_dsl
9
+
10
+ desc "Ejecutar las espectativas de la clase Menu_dsl"
11
+ task :menu_dsl do
12
+ sh "rspec -I. spec/prct11_spec.rb"
13
+ end
14
+
15
+ desc "Ejecutar las espectativas de la clase Lista"
16
+ task :mod do
17
+ sh "rspec -I. spec/prct09_spec.rb"
18
+ end
19
+
20
+
21
+ desc "Ejecutar las espectativas de la clase Lista"
22
+ task :dll do
23
+ sh "rspec -I. spec/prct08_spec.rb"
24
+ end
25
+
26
+ desc "Ejecutar las espectativas de la clase Lista"
27
+ task :lista do
28
+ sh "rspec -I. spec/prct07_spec.rb"
29
+ end
30
+
31
+ desc "Ejecutar las espectativas de la clase Dieta"
32
+ task :spec do
33
+ sh "rspec -I. spec/prct06_spec.rb"
34
+ end
35
+
36
+ desc "Ejecutar con documentación"
37
+ task :doc do
38
+ sh "rspec -I. spec/prct06_spec.rb --format documentation"
39
+ end
40
+
data/bin/_guard-core ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application '_guard-core' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("guard", "_guard-core")
data/bin/bundler ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'bundler' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("bundler", "bundler")
data/bin/coderay ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'coderay' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("coderay", "coderay")
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
data/bin/guard ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'guard' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("guard", "guard")
data/bin/htmldiff ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'htmldiff' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("diff-lcs", "htmldiff")
data/bin/ldiff ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'ldiff' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("diff-lcs", "ldiff")
data/bin/listen ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'listen' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("listen", "listen")
data/bin/pry ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'pry' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("pry", "pry")
data/bin/rake ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rake' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rake", "rake")
data/bin/rspec ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rspec' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
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/bin/thor ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'thor' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("thor", "thor")
data/lib/prct06.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "prct06/version"
2
+ require "prct06/dieta.rb"
3
+ require "prct06/lista.rb"
4
+
5
+ #Modulo generado automaticamente por Bundler.
6
+ module Prct06
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,79 @@
1
+
2
+ #Clase Dieta padre que representa un menu con su titulo, platos y datos correspondientes a los nutrientes.
3
+ class Dieta
4
+ include Comparable
5
+ #Titulo de la dieta.
6
+ attr_accessor :titulo
7
+ #Porcentaje de injesta diaria.
8
+ attr_accessor :ing_diaria
9
+ #Platos que contiene la dieta.
10
+ attr_accessor :platos
11
+ #Calorias de la dieta.
12
+ attr_accessor :vct
13
+ #Porcentaje de calorias.
14
+ attr_accessor :prot
15
+ #Porcentaje de grasas.
16
+ attr_accessor :grasas
17
+ #Porcentaje de carbohidratos.
18
+ attr_accessor :carbo
19
+ #Metodo que inicializa los objetos.
20
+ def initialize(titulo, ing_diaria, platos, vct, prot, grasas, carbo)
21
+ @titulo = titulo
22
+ @ing_diaria = ing_diaria
23
+ @platos = platos
24
+ @vct = vct
25
+ @prot = prot
26
+ @grasas = grasas
27
+ @carbo = carbo
28
+ end
29
+
30
+ #Metodo que formatea la salida de una Dieta.
31
+ def to_s
32
+ title = "#{@titulo} (#{@ing_diaria})\n"
33
+ for i in 0..@platos.size-1
34
+ title+="-#{@platos[i][0]}, #{@platos[i][1]}, #{@platos[i][2]}\n"
35
+ end
36
+ title += "V.C.T. | %\t#{@vct} | #{@prot} - #{@grasas} - #{@carbo}"
37
+ end
38
+
39
+ #Metodo necesario para el uso del modulo Comparable.
40
+ def <=> (an0ther)
41
+ self.vct <=> an0ther.vct
42
+ end
43
+ end
44
+
45
+ #Clase Menu_alimentos que hereda de la clase padre Dieta.
46
+ class Menu_alimentos < Dieta
47
+ #Atributo para el grupo de alimentos.
48
+ attr_accessor :alimentos
49
+
50
+ #Metodo que inicia los objetos.
51
+ def initialize(alimentos, dieta)
52
+ @alimentos = alimentos
53
+ super(dieta.titulo, dieta.ing_diaria, dieta.platos, dieta.vct, dieta.prot, dieta.grasas, dieta.carbo)
54
+ end
55
+
56
+ #Metodo que formatea la salida de una dieta con grupo de alimentos.
57
+ def to_s
58
+ string = super.to_s + "\nGrupo de alimentos: #{alimentos}\n"
59
+ end
60
+
61
+ end
62
+
63
+ #Clase Menu_edad que hereda de la clase padre Dieta.
64
+ class Menu_edad < Dieta
65
+ #Atributo para el rango de edades de los alimentos.
66
+ attr_accessor :edad
67
+
68
+ #Metodo que inicia los objetos.
69
+ def initialize(edad, dieta)
70
+ @edad = edad
71
+ super(dieta.titulo, dieta.ing_diaria, dieta.platos, dieta.vct, dieta.prot, dieta.grasas, dieta.carbo)
72
+ end
73
+
74
+ #Metodo que formatea la salida de una dieta con rango de edades.
75
+ def to_s
76
+ string = super.to_s + "\nEdad: #{@edad}\n"
77
+ end
78
+
79
+ end
@@ -0,0 +1,105 @@
1
+ #Estructura del nodo que contiene el valor, el nodo siguiente, y el nodo anterior.
2
+ Node = Struct.new(:value, :next, :prev)
3
+
4
+ #Clase lista doblemente enlazada.
5
+ class Lista
6
+ include Enumerable
7
+ #Nodo del principio de la lista.
8
+ attr_accessor :head
9
+ #Nodo del final de la lista.
10
+ attr_accessor :tail
11
+
12
+ #Metodo que inicializa los objetos de tipo Lista.
13
+ def initialize
14
+ @head = @tail = nil
15
+ end
16
+
17
+ #Metodo que devuelve true si la lista esta vacia.
18
+ def is_empty
19
+
20
+ if @head==nil && @tail==nil
21
+ return true
22
+ else
23
+ return false
24
+ end
25
+
26
+ end
27
+
28
+ #Metodo que mete un elemento en la lista por el final.
29
+ def push(v)
30
+
31
+ nodo = Node.new(v,nil,nil)
32
+
33
+ if (@head == nil)
34
+ @head = nodo
35
+ else
36
+ @tail.next = nodo
37
+ nodo.prev = @tail
38
+ end
39
+ @tail=nodo
40
+
41
+ end
42
+
43
+ #Metodo que mete un elemento en la lista por el principio.
44
+ def push_head(v)
45
+
46
+ nodo = Node.new(v,nil,nil)
47
+ nodo.next = @head
48
+ nodo.prev=nil
49
+ if @tail==nil
50
+ @final=nodo
51
+ else
52
+ @head.prev=nodo
53
+ end
54
+
55
+ @head = nodo
56
+ end
57
+
58
+ #Metodo que saca un elemento de la lista por el principio.
59
+ def pop
60
+
61
+ if(!is_empty())
62
+ nodo = @head
63
+ @head = @head.next
64
+ return nodo.value
65
+ else
66
+ return nil
67
+ end
68
+
69
+ end
70
+
71
+ #Metodo que saca un elemento de la lista por el final.
72
+ def pop_tail
73
+ if(@tail==nil)
74
+ return false
75
+ else
76
+ nodo = @tail
77
+ @tail = @tail.prev
78
+ end
79
+ return nodo.value
80
+ end
81
+
82
+ #Metodo que formatea la salida de la lista.
83
+ def to_s
84
+ aux=@head
85
+ i=1
86
+ str=""
87
+ while(aux!=nil)
88
+ str+="#{i}) #{aux[:value]}\n"
89
+ aux=aux[:next]
90
+ i+=1
91
+ end
92
+ str
93
+ end
94
+
95
+ #Metodo necesario para el uso del modulo Enumerable.
96
+ def each
97
+ aux=@head
98
+ while(aux!=nil)
99
+ yield aux[:value]
100
+ aux=aux[:next]
101
+ end
102
+ end
103
+
104
+ end
105
+
@@ -0,0 +1,73 @@
1
+ class Menu_dsl
2
+ include Comparable
3
+ #Titulo de la dieta.
4
+ attr_accessor :titulo
5
+ #Porcentaje de injesta diaria.
6
+ attr_accessor :ing_diaria
7
+ #Platos que contiene la dieta.
8
+ attr_accessor :platos
9
+ #Calorias de la dieta.
10
+ attr_accessor :porcentajes
11
+
12
+ def initialize(name, &block)
13
+ @titulo = name
14
+ @ing_diaria = []
15
+ @porcentajes = []
16
+ @platos = []
17
+
18
+ if block_given?
19
+ if block.arity == 1
20
+ yield self
21
+ else
22
+ instance_eval(&block)
23
+ end
24
+ end
25
+ end
26
+
27
+
28
+ def to_s
29
+ output = @titulo
30
+ output << "\n#{'=' * @titulo.size}\n"
31
+ output << "\nMin: #{@ing_diaria[0]}\n"
32
+ output << "Max: #{@ing_diaria[1]}\n\n"
33
+
34
+ @platos.each_with_index do |plato, index|
35
+ output << "#{index + 1}) #{plato[0]}. Porción: #{plato[1]}. Cantidad: #{plato[2]}\n"
36
+ end
37
+
38
+ output << "V.C.T. | %\t#{@porcentajes[0]} kcal | #{@porcentajes[1]}% - #{@porcentajes[2]}% - #{@porcentajes[3]}%\n\n"
39
+ output
40
+ end
41
+
42
+ def ingesta(ing = {})
43
+ i = []
44
+ i << "#{ing[:min]}" if ing[:min]
45
+ i << "#{ing[:max]}" if ing[:max]
46
+ @ing_diaria = i
47
+ end
48
+
49
+ def porcent(porc = {})
50
+ p = []
51
+ p << "#{porc[:vct]}" if porc[:vct]
52
+ p << "#{porc[:proteinas]}" if porc[:proteinas]
53
+ p << "#{porc[:grasas]}" if porc[:grasas]
54
+ p << "#{porc[:hidratos]}" if porc[:hidratos]
55
+
56
+ @porcentajes = p
57
+ end
58
+
59
+ def plat(options = {})
60
+ pl = []
61
+ pl << "#{options[:descripcion]}" if options[:descripcion]
62
+ pl << "#{options[:porcion]}" if options[:porcion]
63
+ pl << "#{options[:gramos]}" if options[:gramos]
64
+
65
+ @platos << pl
66
+ end
67
+
68
+ def <=>(an0ther)
69
+ self.porcentajes[0] <=> an0ther.porcentajes[0]
70
+ end
71
+ end
72
+
73
+
@@ -0,0 +1,4 @@
1
+ module Prct06
2
+ #Constante para la versión del proyecto.
3
+ VERSION = "5.0.0"
4
+ end
data/prct06.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
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 = "prct6lpp"
8
+ spec.version = Prct06::VERSION
9
+ spec.authors = ["Fernando Nantes-Machado"]
10
+ spec.email = ["alu0100897975@ull.edu.es"]
11
+
12
+ spec.summary = "Gema para la prácticas de laboratorio 6, 7, 8 y 9, con la clase Dieta y Lista."
13
+ spec.homepage = "https://github.com/ULL-ESIT-LPP-1617/menu-dietetico-alu100897975"
14
+ spec.license = "MIT"
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.13"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rspec", "~> 3.0"
35
+ spec.add_development_dependency "guard-rspec"
36
+ spec.add_development_dependency "guard-bundler"
37
+ end
metadata ADDED
@@ -0,0 +1,202 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prct6lpp
3
+ version: !ruby/object:Gem::Version
4
+ version: 5.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Fernando Nantes-Machado
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-12-14 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
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-rspec
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-bundler
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
+ description:
84
+ email:
85
+ - alu0100897975@ull.edu.es
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - Guardfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/_guard-core
100
+ - bin/bundler
101
+ - bin/coderay
102
+ - bin/console
103
+ - bin/guard
104
+ - bin/htmldiff
105
+ - bin/ldiff
106
+ - bin/listen
107
+ - bin/pry
108
+ - bin/rake
109
+ - bin/rspec
110
+ - bin/setup
111
+ - bin/thor
112
+ - doc/CODE_OF_CONDUCT_md.html
113
+ - doc/Dieta.html
114
+ - doc/Gemfile.html
115
+ - doc/Gemfile_lock.html
116
+ - doc/Guardfile.html
117
+ - doc/LICENSE_txt.html
118
+ - doc/Lista.html
119
+ - doc/Menu_alimentos.html
120
+ - doc/Menu_edad.html
121
+ - doc/Object.html
122
+ - doc/Prct06.html
123
+ - doc/README_md.html
124
+ - doc/Rakefile.html
125
+ - doc/bin/setup.html
126
+ - doc/created.rid
127
+ - doc/css/fonts.css
128
+ - doc/css/rdoc.css
129
+ - doc/fonts/Lato-Light.ttf
130
+ - doc/fonts/Lato-LightItalic.ttf
131
+ - doc/fonts/Lato-Regular.ttf
132
+ - doc/fonts/Lato-RegularItalic.ttf
133
+ - doc/fonts/SourceCodePro-Bold.ttf
134
+ - doc/fonts/SourceCodePro-Regular.ttf
135
+ - doc/images/add.png
136
+ - doc/images/arrow_up.png
137
+ - doc/images/brick.png
138
+ - doc/images/brick_link.png
139
+ - doc/images/bug.png
140
+ - doc/images/bullet_black.png
141
+ - doc/images/bullet_toggle_minus.png
142
+ - doc/images/bullet_toggle_plus.png
143
+ - doc/images/date.png
144
+ - doc/images/delete.png
145
+ - doc/images/find.png
146
+ - doc/images/loadingAnimation.gif
147
+ - doc/images/macFFBgHack.png
148
+ - doc/images/package.png
149
+ - doc/images/page_green.png
150
+ - doc/images/page_white_text.png
151
+ - doc/images/page_white_width.png
152
+ - doc/images/plugin.png
153
+ - doc/images/ruby.png
154
+ - doc/images/tag_blue.png
155
+ - doc/images/tag_green.png
156
+ - doc/images/transparent.png
157
+ - doc/images/wrench.png
158
+ - doc/images/wrench_orange.png
159
+ - doc/images/zoom.png
160
+ - doc/index.html
161
+ - doc/js/darkfish.js
162
+ - doc/js/jquery.js
163
+ - doc/js/navigation.js
164
+ - doc/js/navigation.js.gz
165
+ - doc/js/search.js
166
+ - doc/js/search_index.js
167
+ - doc/js/search_index.js.gz
168
+ - doc/js/searcher.js
169
+ - doc/js/searcher.js.gz
170
+ - doc/prct06_gemspec.html
171
+ - doc/table_of_contents.html
172
+ - lib/prct06.rb
173
+ - lib/prct06/dieta.rb
174
+ - lib/prct06/lista.rb
175
+ - lib/prct06/menu_dsl.rb
176
+ - lib/prct06/version.rb
177
+ - prct06.gemspec
178
+ homepage: https://github.com/ULL-ESIT-LPP-1617/menu-dietetico-alu100897975
179
+ licenses:
180
+ - MIT
181
+ metadata: {}
182
+ post_install_message:
183
+ rdoc_options: []
184
+ require_paths:
185
+ - lib
186
+ required_ruby_version: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ version: '0'
191
+ required_rubygems_version: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ requirements: []
197
+ rubyforge_project:
198
+ rubygems_version: 2.5.1
199
+ signing_key:
200
+ specification_version: 4
201
+ summary: Gema para la prácticas de laboratorio 6, 7, 8 y 9, con la clase Dieta y Lista.
202
+ test_files: []