NutrientesEdu 0.1.1

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: 1c21daba0e8de456f0f8dd4b79f9aa8d530339cb
4
+ data.tar.gz: 16b258d7bcba6faee07ef166fa5c53fc6cfa189a
5
+ SHA512:
6
+ metadata.gz: 8bc43e4e45e99f5cca9b0247c350d6fde51786049795c4faf7d4b099c66625f241a9ca8b65f81eea075ca69006e51b1f2109da0e82031babbf5e8a6e0d6127d6
7
+ data.tar.gz: 047dd918e1b67ac91ed83f4811751a8757bc8ec8c716121c0f7909c90a5580f77c3539c13153794eb2499bb165349fa69f859f28568f4ffc56a1fdb0f2f19a7b
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/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.3.4
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 dimion0096@gmail.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 NutrientesEdu.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,113 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ NutrientesEdu (0.1.1)
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.4.2)
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
+ NutrientesEdu!
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.1
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/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Eduardo
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
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "NutrientesEdu/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "NutrientesEdu"
7
+ spec.version = NutrientesEdu::VERSION
8
+ spec.authors = ["Eduardo"]
9
+ spec.email = ["alu0100991659@ull.edu.es"]
10
+
11
+ spec.summary = %q{Esta gema trabaja con los alimentos}
12
+ spec.homepage = "https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100991659"
13
+ spec.license = "MIT"
14
+
15
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata["allowed_push_host"] = 'https://rubygems.org'
19
+
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.17"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "rspec", "~> 3.0"
37
+ spec.add_development_dependency "guard"
38
+ spec.add_development_dependency "guard-rspec"
39
+ spec.add_development_dependency "guard-bundler"
40
+ spec.add_development_dependency "yard", "~> 0.9.2"
41
+ spec.add_development_dependency "coveralls"
42
+
43
+ end
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # NutrientesEdu
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/NutrientesEdu`. 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 'NutrientesEdu'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install NutrientesEdu
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]/NutrientesEdu. 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 NutrientesEdu project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/NutrientesEdu/blob/master/CODE_OF_CONDUCT.md).
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 "NutrientesEdu"
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
+ bundle install guard
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,98 @@
1
+ require "NutrientesEdu/version"
2
+
3
+ class DietaDia
4
+ include Comparable
5
+
6
+ attr_reader :nombre, :desayuno, :almuerzo, :cena, :conversiones
7
+
8
+ def initialize(nombre, &bloque)
9
+ @conversiones = [
10
+ ["1 rodaja", 20],
11
+ ["1 porcion", 100],
12
+ ["1 taza", 180],
13
+ ["1/2 cucharon",18],
14
+ ["1 pieza", 135],
15
+ ["1 vaso", 100]]
16
+ @nombre = nombre
17
+ @desayuno = Menu.new()
18
+ @almuerzo = Menu.new()
19
+ @cena = Menu.new()
20
+ if block_given?
21
+ if bloque.arity == 1
22
+ yield self
23
+ else
24
+ instance_eval(&bloque)
25
+ end
26
+ end
27
+ end
28
+
29
+
30
+ def kcal
31
+ @desayuno.kcal + @almuerzo.kcal + @cena.kcal
32
+ end
33
+
34
+
35
+ def is_enough(persona)
36
+ x = kcal
37
+ return (persona.g_en_total <= x * 1.1) && (persona.g_en_total >= x * 0.9)
38
+ end
39
+
40
+
41
+ def <=>(other)
42
+ kcal <=> other.kcal
43
+ end
44
+
45
+
46
+
47
+ def to_s
48
+ texto = @nombre
49
+ texto << "\n#{'=' * @nombre.size}\n"
50
+ texto << "Composicion nutricional: \n"
51
+ texto << "Desayuno: "
52
+ texto << "\n"
53
+ texto << @desayuno.to_s
54
+ texto << "Almuerzo: "
55
+ texto << "\n"
56
+ texto << @almuerzo.to_s
57
+ texto << "Cena: "
58
+ texto << "\n"
59
+ texto << @cena.to_s
60
+ texto << "Kcal totales: "
61
+ texto << "#{kcal}"
62
+ texto << "\n"
63
+ return texto
64
+ end
65
+
66
+
67
+ def desayuno(options = {})
68
+ porcion = 0
69
+ @conversiones.each do
70
+ |x|
71
+ porcion = x[1] if x[0] == options[:porcion]
72
+ end
73
+ multiplier = porcion / options[:gramos]
74
+ @desayuno.push_tail(Alimento.new(options[:descripcion],options[:grasas] * multiplier,0,options[:carbohidratos] * multiplier,0,options[:proteinas] * multiplier,options[:sal] * multiplier))
75
+ end
76
+
77
+
78
+ def almuerzo(options = {})
79
+ porcion = 0
80
+ @conversiones.each do
81
+ |x|
82
+ porcion = x[1] if x[0] == options[:porcion]
83
+ end
84
+ multiplier = porcion / options[:gramos]
85
+ @almuerzo.push_tail(Alimento.new(options[:descripcion],options[:grasas] * multiplier,0,options[:carbohidratos] * multiplier,0,options[:proteinas] * multiplier,options[:sal] * multiplier))
86
+ end
87
+
88
+
89
+ def cena(options = {})
90
+ porcion = 0
91
+ @conversiones.each do
92
+ |x|
93
+ porcion = x[1] if x[0] == options[:porcion]
94
+ end
95
+ multiplier = porcion / options[:gramos]
96
+ @cena.push_tail(Alimento.new(options[:descripcion],options[:grasas] * multiplier,0,options[:carbohidratos] * multiplier,0,options[:proteinas] * multiplier,options[:sal] * multiplier))
97
+ end
98
+ end
@@ -0,0 +1,28 @@
1
+ class IMC
2
+ include Comparable
3
+
4
+ attr_reader :peso, :altura, :edad, :sexo
5
+
6
+ def initialize(a,b,c,d)
7
+ @peso=a
8
+ @altura=b
9
+ @edad=c
10
+ @sexo=d
11
+ end
12
+
13
+ def calcular_imc
14
+ (@peso)/(@altura*@altura)
15
+ end
16
+
17
+ def porcentaje_grasa
18
+ ((1.2*calcular_imc)+(0.23*edad)-(10.8*sexo)-5.4)
19
+ end
20
+
21
+ def to_s
22
+ "#{@peso} #{@altura} #{@edad} #{@sexo}"
23
+ end
24
+
25
+ def <=> (other)
26
+ calcular_imc <=> other.calcular_imc
27
+ end
28
+ end
@@ -0,0 +1,59 @@
1
+ require "NutrientesEdu/version"
2
+ require "NutrientesEdu/IMC"
3
+
4
+ class Individuos < IMC
5
+
6
+ include Comparable
7
+ attr_reader :nombre, :paciente, :tratamiento
8
+
9
+ def initialize(nombre, paciente, tratamiento, peso, talla, edad, sexo, f_af)
10
+ @nombre=nombre
11
+ @paciente=paciente
12
+ @tratamiento=tratamiento
13
+ @f_af=f_af
14
+ @peso=peso
15
+ @talla=talla
16
+ @edad=edad
17
+ @sexo=sexo
18
+ if @paciente==1
19
+ super(peso,talla,edad,sexo)
20
+ end
21
+ end
22
+
23
+ def clas_imc
24
+ if calcular_imc < 30
25
+ return "Normal"
26
+ else
27
+ return "Obeso"
28
+ end
29
+ end
30
+
31
+ def g_e_basal
32
+ if(@sexo == 0)
33
+ return 10*@peso+6.25*@talla-5*@edad-161
34
+ else
35
+ return 10*@peso+6.25*@talla-5*@edad+5
36
+ end
37
+ end
38
+
39
+ def e_term
40
+ return g_e_basal*0.10
41
+ end
42
+
43
+ def g_act_fis
44
+ return g_e_basal*@f_af
45
+ end
46
+
47
+ def g_en_total
48
+ return g_e_basal+e_term+g_act_fis
49
+ end
50
+
51
+
52
+ def to_s
53
+ rval = "#{@nombre} #{g_en_total}"
54
+ if(@tratamiento == 1)
55
+ rval += super
56
+ end
57
+ return rval
58
+ end
59
+ end
@@ -0,0 +1,107 @@
1
+ require "NutrientesEdu/version"
2
+
3
+ Node = Struct.new(:value, :next, :prev)
4
+
5
+ class Lista
6
+
7
+ include Enumerable
8
+ include Comparable
9
+ attr_reader :head, :tail
10
+
11
+ def push_head(value)
12
+ if(@head == nil)
13
+ node=Node.new(value,nil,nil)
14
+ @head = node
15
+ @tail = node
16
+
17
+ else
18
+ node=Node.new(value,@head,nil)
19
+ @head.prev = node
20
+ @head = node
21
+
22
+ end
23
+ end
24
+
25
+ def push_tail(value)
26
+ if(@tail == nil)
27
+ node=Node.new(value,nil,nil)
28
+ @head = node
29
+ @tail = node
30
+ else
31
+ node=Node.new(value,nil,@tail)
32
+ @tail.next = node
33
+ @tail = node
34
+ end
35
+ end
36
+
37
+ def pop_head()
38
+ if(@head == nil)
39
+ return nil
40
+ else
41
+ val= @head
42
+ node = @head.next
43
+ @head = node
44
+ if @head != nil
45
+ @head.prev = nil
46
+ end
47
+ return val
48
+ end
49
+ end
50
+
51
+ def pop_tail()
52
+ if(@tail == nil)
53
+ return nil
54
+ else
55
+ val = @tail
56
+ node = @tail.prev
57
+ @tail = node
58
+ if @tail != nil
59
+ @tail.next = nil
60
+ end
61
+ return val
62
+ end
63
+ end
64
+
65
+ def sort_salt
66
+ v = []
67
+ j = 0
68
+ each do
69
+ |i| v[j] = i
70
+ j += 1
71
+ end
72
+ terminado = false
73
+ while !terminado
74
+ terminado = true
75
+ for k in 0..(v.length)-2
76
+ if v[k].sal > v[k+1].sal
77
+ aux = v[k+1]
78
+ v[k+1] = v[k]
79
+ v[k] = aux
80
+ terminado = false
81
+ end
82
+ end
83
+ end
84
+ listadef = Lista.new()
85
+ for k in 0..(v.length)-1
86
+ listadef.push_tail(v[k])
87
+ end
88
+ return listadef
89
+ end
90
+
91
+ def to_s
92
+ s = ""
93
+ each {|i| s += "#{i.to_s}\n"}
94
+ s
95
+ end
96
+
97
+ def each
98
+ x = @head
99
+ while(x != nil)
100
+ yield x.value
101
+ x = x.next
102
+ end
103
+ end
104
+
105
+
106
+
107
+ end
@@ -0,0 +1,21 @@
1
+ require "NutrientesEdu/version"
2
+
3
+ class Menu < Lista
4
+ include Comparable
5
+
6
+ def kcal
7
+ x = collect{|a| a.val_ener}
8
+ y = x.inject(0, :+)
9
+ y
10
+ end
11
+
12
+ def is_enough(persona)
13
+ x = kcal
14
+ return (persona.g_en_total <= x * 1.1) && (persona.g_en_total >= x * 0.9)
15
+ end
16
+
17
+
18
+ def <=>(other)
19
+ kcal <=> other.kcal
20
+ end
21
+ end
@@ -0,0 +1,34 @@
1
+ require "NutrientesEdu/version"
2
+
3
+ class Alimento
4
+
5
+ include Comparable
6
+
7
+ attr_reader :nombre, :grasas, :grsat, :carbs, :azucar, :protein, :sal
8
+
9
+ def initialize(nombre, grasas, grsat, carbs, azucar, protein, sal)
10
+ @nombre = nombre
11
+ @grasas = grasas
12
+ @grsat = grsat
13
+ @carbs = carbs
14
+ @azucar = azucar
15
+ @protein = protein
16
+ @sal = sal
17
+
18
+ end
19
+
20
+ def val_ener
21
+ (grasas*9+carbs*4+protein*4)
22
+ end
23
+
24
+
25
+ def to_s
26
+ "Nombre: #{@nombre}, Grasas: #{@grasas}, Saturadas: #{@grsat}, Carbohidratos: #{@carbs}, Azucar: #{@azucar}, Proteinas: #{@protein}, Sal: #{@sal} Kcal: #{val_ener}
27
+ "
28
+ end
29
+
30
+ def <=> (other)
31
+ val_ener <=> other.val_ener
32
+ end
33
+
34
+ end
@@ -0,0 +1,24 @@
1
+
2
+ module NutrientesEdu
3
+ VERSION = "0.1.1"
4
+ end
5
+
6
+ class Lista
7
+ VERSION = "0.1.0"
8
+ end
9
+
10
+ class IMC
11
+ VERSION = "0.1.0"
12
+ end
13
+
14
+ class Individuos < IMC
15
+ VERSION = "0.1.0"
16
+ end
17
+
18
+ class Manu
19
+ VERSION = "0.1.0"
20
+ end
21
+
22
+ class DietaDia
23
+ VERSION = "0.1.0"
24
+ end
metadata ADDED
@@ -0,0 +1,176 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: NutrientesEdu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Eduardo
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:
126
+ email:
127
+ - alu0100991659@ull.edu.es
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".travis.yml"
134
+ - CODE_OF_CONDUCT.md
135
+ - Gemfile
136
+ - Gemfile.lock
137
+ - Guardfile
138
+ - LICENSE.txt
139
+ - NutrientesEdu.gemspec
140
+ - README.md
141
+ - Rakefile
142
+ - bin/console
143
+ - bin/setup
144
+ - lib/NutrientesEdu/DietaDiaria.rb
145
+ - lib/NutrientesEdu/IMC.rb
146
+ - lib/NutrientesEdu/Individuo.rb
147
+ - lib/NutrientesEdu/Lista.rb
148
+ - lib/NutrientesEdu/Menu.rb
149
+ - lib/NutrientesEdu/NutrientesEdu.rb
150
+ - lib/NutrientesEdu/version.rb
151
+ homepage: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100991659
152
+ licenses:
153
+ - MIT
154
+ metadata:
155
+ allowed_push_host: https://rubygems.org
156
+ post_install_message:
157
+ rdoc_options: []
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ requirements: []
171
+ rubyforge_project:
172
+ rubygems_version: 2.6.11
173
+ signing_key:
174
+ specification_version: 4
175
+ summary: Esta gema trabaja con los alimentos
176
+ test_files: []