prct06_alu0100958607 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1b3ca11ee34d808835d97a10f41f6e24f7208cbd091db34be87b56d4ffa451bb
4
+ data.tar.gz: eac7b242079070ea11a49b321e5e847a15207b1875f9bf3448030bb1c22c4761
5
+ SHA512:
6
+ metadata.gz: 51d6ec797fdd2445b31bf82898089aff6d8b56cfbe75c5f3cfc66245665ee120bde39e5ebcbce23e6ae247bbe19e024827c0920d278bfeab1105118edfb5ab8b
7
+ data.tar.gz: a882648a027d8588c34acb2e31fadcbe4e16a8eacea5f56efa871adccfc1a07d447d1eac7981e35e776a6c851861ae318a61def8aa35b687ea6de71662b8420e
data/.Rakefile.swp ADDED
Binary file
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
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 alu0100958607@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,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in prct06.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,111 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ prct06 (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.2)
10
+ coveralls (0.7.1)
11
+ multi_json (~> 1.3)
12
+ rest-client
13
+ simplecov (>= 0.7)
14
+ term-ansicolor
15
+ thor
16
+ diff-lcs (1.3)
17
+ docile (1.3.1)
18
+ domain_name (0.5.20180417)
19
+ unf (>= 0.0.5, < 1.0.0)
20
+ ffi (1.9.25)
21
+ formatador (0.2.5)
22
+ guard (2.15.0)
23
+ formatador (>= 0.2.4)
24
+ listen (>= 2.7, < 4.0)
25
+ lumberjack (>= 1.0.12, < 2.0)
26
+ nenv (~> 0.1)
27
+ notiffany (~> 0.0)
28
+ pry (>= 0.9.12)
29
+ shellany (~> 0.0)
30
+ thor (>= 0.18.1)
31
+ guard-bundler (2.1.0)
32
+ bundler (~> 1.0)
33
+ guard (~> 2.2)
34
+ guard-compat (~> 1.1)
35
+ guard-compat (1.2.1)
36
+ guard-rspec (4.7.3)
37
+ guard (~> 2.1)
38
+ guard-compat (~> 1.1)
39
+ rspec (>= 2.99.0, < 4.0)
40
+ http-cookie (1.0.3)
41
+ domain_name (~> 0.5)
42
+ json (2.1.0)
43
+ listen (3.1.5)
44
+ rb-fsevent (~> 0.9, >= 0.9.4)
45
+ rb-inotify (~> 0.9, >= 0.9.7)
46
+ ruby_dep (~> 1.2)
47
+ lumberjack (1.0.13)
48
+ method_source (0.9.2)
49
+ mime-types (3.2.2)
50
+ mime-types-data (~> 3.2015)
51
+ mime-types-data (3.2018.0812)
52
+ multi_json (1.13.1)
53
+ nenv (0.3.0)
54
+ netrc (0.11.0)
55
+ notiffany (0.1.1)
56
+ nenv (~> 0.1)
57
+ shellany (~> 0.0)
58
+ pry (0.12.2)
59
+ coderay (~> 1.1.0)
60
+ method_source (~> 0.9.0)
61
+ rake (10.5.0)
62
+ rb-fsevent (0.10.3)
63
+ rb-inotify (0.9.10)
64
+ ffi (>= 0.5.0, < 2)
65
+ rest-client (2.0.2)
66
+ http-cookie (>= 1.0.2, < 2.0)
67
+ mime-types (>= 1.16, < 4.0)
68
+ netrc (~> 0.8)
69
+ rspec (3.8.0)
70
+ rspec-core (~> 3.8.0)
71
+ rspec-expectations (~> 3.8.0)
72
+ rspec-mocks (~> 3.8.0)
73
+ rspec-core (3.8.0)
74
+ rspec-support (~> 3.8.0)
75
+ rspec-expectations (3.8.2)
76
+ diff-lcs (>= 1.2.0, < 2.0)
77
+ rspec-support (~> 3.8.0)
78
+ rspec-mocks (3.8.0)
79
+ diff-lcs (>= 1.2.0, < 2.0)
80
+ rspec-support (~> 3.8.0)
81
+ rspec-support (3.8.0)
82
+ ruby_dep (1.5.0)
83
+ shellany (0.0.1)
84
+ simplecov (0.16.1)
85
+ docile (~> 1.1)
86
+ json (>= 1.8, < 3)
87
+ simplecov-html (~> 0.10.0)
88
+ simplecov-html (0.10.2)
89
+ term-ansicolor (1.7.0)
90
+ tins (~> 1.0)
91
+ thor (0.20.3)
92
+ tins (1.20.2)
93
+ unf (0.1.4)
94
+ unf_ext
95
+ unf_ext (0.0.7.5)
96
+
97
+ PLATFORMS
98
+ ruby
99
+
100
+ DEPENDENCIES
101
+ bundler (~> 1.17)
102
+ coveralls
103
+ guard
104
+ guard-bundler
105
+ guard-rspec
106
+ prct06!
107
+ rake (~> 10.0)
108
+ rspec (~> 3.0)
109
+
110
+ BUNDLED WITH
111
+ 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 Sergio Rodriguez
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,43 @@
1
+ # Prct06
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/prct06`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: 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 'prct06'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install prct06
22
+
23
+ ## Usage
24
+
25
+ TODO: 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]/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.
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 Prct06 project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/prct06/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 "prct06"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/prct06.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "prct06/version"
2
+ require "nutrition.rb"
3
+
4
+ module Prct06
5
+ class Error < StandardError; end
6
+ # Your code goes here...
7
+ end
Binary file
Binary file
@@ -0,0 +1,62 @@
1
+ require 'prct06/guy.rb'
2
+
3
+ class Antro < Guy
4
+
5
+ include Comparable
6
+ #Definicion de atributos de la clase
7
+ attr_reader :peso, :altura, :edad, :sexo, :cintura, :cadera, :actividad
8
+
9
+ #Definicion del metodo initialize de la clase antropometrico
10
+ def initialize(peso, altura, edad, sexo, cintura, cadera, actividad)
11
+ @peso ,@altura ,@edad ,@sexo, @cintura, @cadera, @actividad = peso, altura, edad, sexo, cintura, cadera, actividad
12
+ end
13
+
14
+ #Función que calcula el imc de una persona
15
+ def imc
16
+ @imc = (@peso)/(@altura*@altura)
17
+ end
18
+
19
+ #Función que calcula el porcentaje de grasa de una persona
20
+ def pgc
21
+ @pgc = 1.2 * @imc + 0.23 * @edad - 10.8 * @sexo - 5.4
22
+ @pgc.round(4)
23
+ end
24
+
25
+ #Función que calcula el RCC de una persona
26
+ def rcc
27
+ @rcc = @cintura.to_f / @cadera.to_f
28
+ end
29
+
30
+ #Funcion para calcular el gasto energetico total
31
+ def g_energetico
32
+ if(@sexo == 1)
33
+ @g_energetico_basal = (10 * @peso) + (6.25 * @altura) - (5 * @edad) + 5
34
+ else
35
+ @g_energetico_basal = (10 * @peso) + (6.25 * @altura) - (5 * @edad) - 161
36
+ end
37
+
38
+ @efecto_termogeno = @g_energetico_basal * 0.1
39
+
40
+ if (@actividad == "reposo")
41
+ @factor_Actividad = 0.0
42
+ elsif (@actividad == "ligera")
43
+ @factor_Actividad = 0.12
44
+ elsif (@actividad == "moderada")
45
+ @factor_Actividad = 0.27
46
+ else
47
+ @factor_Actividad = 0.54
48
+ end
49
+
50
+ @gasto_actividad = @g_energetico_basal.to_f * @factor_actividad.to_f
51
+
52
+ @g_energetico = @g_energetico_basal + @efecto_termogeno + @gasto_actividad
53
+
54
+ return @g_energetico
55
+
56
+ end
57
+
58
+ #Función de sobrecarga de los operadores comparables
59
+ def <=> (other)
60
+ imc <=> other.imc
61
+ end
62
+ end
@@ -0,0 +1,34 @@
1
+ class Array
2
+
3
+ def sort_for
4
+
5
+ @aux = self
6
+
7
+ for x in 0..self.length-1
8
+ for y in 0..length-2-x
9
+ if ( @aux[y] > @aux[y+1] )
10
+ @aux[y], @aux[y+1] = @aux[y+1], @aux[y]
11
+ end
12
+ end
13
+ end
14
+
15
+ return @aux
16
+
17
+ end
18
+
19
+ def sort_each
20
+
21
+ @aux = self
22
+ @pos = 0
23
+
24
+ @aux.each do |x|
25
+ @pos = @pos + 1
26
+ @aux[@pos..@aux.length-1] do |y|
27
+ if (x>y)
28
+ x, y = y, x
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ end
data/lib/prct06/guy.rb ADDED
@@ -0,0 +1,9 @@
1
+ class Guy
2
+ #Definición de atributos de clase Guy
3
+ attr_reader :nombre, :dni
4
+
5
+ #Función initialize de la clase Guy
6
+ def initialize(nombre, dni)
7
+ @nombre, @dni=nombre, dni
8
+ end
9
+ end
@@ -0,0 +1,146 @@
1
+ Node = Struct.new(:value, :nexst, :prev)
2
+
3
+ class List
4
+
5
+ include Enumerable
6
+ #Atributos de clase List
7
+ attr_reader :head, :tail
8
+
9
+ #Función initialize de la clase List
10
+ def initialize(head, tail)
11
+ @head=head
12
+ @tail=tail
13
+ end
14
+
15
+ #Método de inserción
16
+ def insert(value)
17
+ node = Node.new(value, nil, nil)
18
+ if(@tail==nil)
19
+ @tail=node
20
+ @head=node
21
+ else
22
+ node.prev=@tail
23
+ @tail.nexst=node
24
+ @tail=node
25
+ end
26
+ end
27
+
28
+ #Método de extracción
29
+ def extract
30
+ if(@head==nil)
31
+ puts "Lista vacia"
32
+ else
33
+ aux=@head
34
+ @head=@head.nexst
35
+ if(@head!=nil)
36
+ @head.prev=nil
37
+ end
38
+ aux.nexst=nil
39
+ if(@head==nil)
40
+ @tail=nil
41
+ end
42
+ return aux
43
+ end
44
+ end
45
+
46
+ #Función que retorna si la lista es vacia o no
47
+ def empty
48
+ if(@tail==nil)
49
+ return true
50
+ else
51
+ return false
52
+ end
53
+ end
54
+
55
+ #Metodo de inserción por la cabeza
56
+ def insert_head(value)
57
+ node = Node.new(value, nil, nil)
58
+
59
+ if(@head==nil)
60
+ @tail=node
61
+ @head=node
62
+ else
63
+ node.nexst=@head
64
+ @head.prev=node
65
+ @head=node
66
+ end
67
+ end
68
+
69
+ #Método de extracción por la cola
70
+ def extract_tail
71
+ if(@tail==nil)
72
+ puts "Lista vacia"
73
+ else
74
+ aux=tail
75
+ @tail=@tail.prev
76
+ if(@tail!=nil)
77
+ @tail.nexst=nil
78
+ end
79
+ aux.prev=nil
80
+
81
+ if(@tail==nil)
82
+ @head=nil
83
+ end
84
+ return aux
85
+ end
86
+ end
87
+
88
+ #Método to_s que combierte la clase a string
89
+ def to_s
90
+ aux=@head
91
+ string="["
92
+
93
+ if(@head!=nil)
94
+ while aux!=nil do
95
+ string+=aux.value.to_s+","
96
+ if(aux.nexst!=nil)
97
+ aux=aux.nexst
98
+ else
99
+ aux=nil
100
+ end
101
+ end
102
+ string+="]"
103
+ end
104
+
105
+ return string
106
+ end
107
+
108
+ #Funciones enumerables de la clase
109
+ def each(&block)
110
+ aux = @head
111
+ while aux!=nil do
112
+ yield aux.value
113
+ aux = aux.nexst
114
+ end
115
+ end
116
+
117
+ def sort_for
118
+ @aux = self.map { |x| x }
119
+
120
+ for x in 0..@aux.length-1
121
+ for y in 0..@aux.length-2-x
122
+ if ( @aux[y] > @aux[y+1] )
123
+ @aux[y], @aux[y+1] = @aux[y+1], @aux[y]
124
+ end
125
+ end
126
+ end
127
+
128
+ return @aux
129
+
130
+ end
131
+
132
+ def sort_each
133
+
134
+ @aux = self.map { |x| x}
135
+ @pos = 0
136
+
137
+ @aux.each do |x|
138
+ @pos = @pos + 1
139
+ @aux[@pos..@aux.length-1] do |y|
140
+ if (x>y)
141
+ x, y = y, x
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,194 @@
1
+ class Menu
2
+ attr_accessor :name, :ingredients, :instructions
3
+
4
+ def initialize(name, &block)
5
+ @desayuno_array = []
6
+ @almuerzo = []
7
+ @cena = []
8
+ @titulo
9
+ @ingesta = []
10
+ @name = name
11
+ @ingredients = []
12
+ @instructions = []
13
+ @valor_energetico = 0
14
+
15
+ if block_given?
16
+ if block.arity == 1
17
+ yield self
18
+ else
19
+ instance_eval(&block)
20
+ end
21
+ end
22
+ end
23
+
24
+ def to_s
25
+
26
+ puts @name
27
+ puts "\t \t \t Composición nutricional"
28
+ puts "\n#{'=' *100}\n\n"
29
+ puts "\t \t \t Grasa \t Carbohidratos \t Proteinas \t fibra \t sal \t valor energético \n \n "
30
+
31
+ @valor_total = 0
32
+
33
+ @desayuno_array.each do |elemento|
34
+ if elemento[:descripcion] == nil
35
+ elemento[:descripcion] = 0.00
36
+ end
37
+ if elemento[:fibra] == nil
38
+ elemento[:fibra] = 0.00
39
+ end
40
+ if elemento[:grasas] == nil
41
+ elemento[:grasas] = 0.00
42
+ end
43
+ if elemento[:carbohidratos] == nil
44
+ elemento[:carbohidratos] = 0.00
45
+ end
46
+ if elemento[:proteinas] == nil
47
+ elemento[:proteinas] = 0.00
48
+ end
49
+ if elemento[:sal] == nil
50
+ elemento[:sal] = 0.00
51
+ end
52
+ print elemento[:descripcion]
53
+ print "\t #{elemento[:grasas]}"
54
+ print "\t #{elemento[:carbohidratos]}"
55
+ print "\t \t #{elemento[:proteinas]}"
56
+ print "\t \t #{elemento[:fibra]}"
57
+ print "\t #{elemento[:sal]}"
58
+ print "\t #{@valor_energetico = (elemento[:grasas]*9 + elemento[:carbohidratos]*4 + elemento[:proteinas]*4 +elemento[:fibra]*2 + elemento[:sal]*6)/10}"
59
+ puts
60
+ @valor_total += @valor_energetico
61
+ end
62
+
63
+ @almuerzo.each do |elemento|
64
+ if elemento[:descripcion] == nil
65
+ elemento[:descripcion] = 0.00
66
+ end
67
+ if elemento[:fibra] == nil
68
+ elemento[:fibra] = 0.00
69
+ end
70
+ if elemento[:grasas] == nil
71
+ elemento[:grasas] = 0.00
72
+ end
73
+ if elemento[:carbohidratos] == nil
74
+ elemento[:carbohidratos] = 0.00
75
+ end
76
+ if elemento[:proteinas] == nil
77
+ elemento[:proteinas] = 0.00
78
+ end
79
+ if elemento[:sal] == nil
80
+ elemento[:sal] = 0.00
81
+ end
82
+
83
+ print "#{elemento[:descripcion]}"
84
+ print "\t \t #{elemento[:grasas]}"
85
+ print "\t #{elemento[:carbohidratos]}"
86
+ print "\t \t#{elemento[:proteinas]}"
87
+ print "\t \t#{elemento[:fibra]}"
88
+ print "\t #{elemento[:sal]}"
89
+ print "\t #{@valor_energetico = (elemento[:grasas]*9 + elemento[:carbohidratos]*4 + elemento[:proteinas]*4 +elemento[:fibra]*2 + elemento[:sal]*6)/10}"
90
+ puts
91
+ @valor_total += @valor_energetico
92
+ end
93
+
94
+ @cena.each do |elemento|
95
+ if elemento[:descripcion] == nil
96
+ elemento[:descripcion] = 0.00
97
+ end
98
+ if elemento[:fibra] == nil
99
+ elemento[:fibra] = 0.00
100
+ end
101
+ if elemento[:grasas] == nil
102
+ elemento[:grasas] = 0.00
103
+ end
104
+ if elemento[:carbohidratos] == nil
105
+ elemento[:carbohidratos] = 0.00
106
+ end
107
+ if elemento[:proteinas] == nil
108
+ elemento[:proteinas] = 0.00
109
+ end
110
+ if elemento[:sal] == nil
111
+ elemento[:sal] = 0.00
112
+ end
113
+ print elemento[:descripcion]
114
+ print " \t #{elemento[:grasas]}"
115
+ print " \t #{elemento[:carbohidratos]}"
116
+ print "\t \t #{elemento[:proteinas]}"
117
+ print "\t \t #{elemento[:fibra]}"
118
+ print "\t #{elemento[:sal]}"
119
+ print " \t #{@valor_energetico = (elemento[:grasas]*9 + elemento[:carbohidratos]*4 + elemento[:proteinas]*4 +elemento[:fibra]*2 + elemento[:sal]*6)/10}"
120
+ puts
121
+ @valor_total += @valor_energetico
122
+ end
123
+ print "Valor energético total #{@valor_total}"
124
+ puts
125
+ puts
126
+ puts
127
+ puts
128
+ puts
129
+ puts "\n#{'=' *100}\n\n"
130
+ end
131
+
132
+
133
+
134
+ def titulo(name)
135
+ @titulo = name
136
+ end
137
+
138
+
139
+
140
+ def ingesta(name,options = {})
141
+ ingesta = name
142
+ ingesta << "(#{options[:min]}" if options[:min]
143
+ ingesta << "(#{options[:max]}" if options[:max]
144
+
145
+ @ingesta << ingesta
146
+ end
147
+
148
+
149
+
150
+ def desayuno(name, options = {})
151
+ desayuno = name
152
+ desayuno << "(#{options[:descripcion]}" if options[:descripcion]
153
+ desayuno << "(#{options[:porcion]}" if options[:porcion]
154
+ desayuno << "(#{options[:grasas]}" if options[:grasas]
155
+ desayuno << "(#{options[:gramos]}" if options[:gramos]
156
+ desayuno << "(#{options[:carbohidratos]}" if options[:carbohidratos]
157
+ desayuno << "(#{options[:proteinas]}" if options[:proteinas]
158
+ desayuno << "(#{options[:fibra]}" if options[:fibra]
159
+ desayuno << "(#{options[:sal]}" if options[:sal]
160
+
161
+ @desayuno_array << desayuno
162
+
163
+ end
164
+
165
+
166
+ def almuerzo(name,options = {})
167
+ almuerzo = name
168
+ almuerzo << "(#{options[:descripcion]}" if options[:descripcion]
169
+ almuerzo << "(#{options[:porcion]}" if options[:porcion]
170
+ almuerzo << "(#{options[:grasas]}" if options[:grasas]
171
+ almuerzo << "(#{options[:carbohidratos]}" if options[:carbohidratos]
172
+ almuerzo << "(#{options[:proteinas]}" if options[:proteinas]
173
+ almuerzo << "(#{options[:fibra]}" if options[:fibra]
174
+ almuerzo << "(#{options[:sal]}" if options[:sal]
175
+
176
+ @almuerzo << almuerzo
177
+ end
178
+
179
+
180
+ def cena(name, options = {})
181
+ cena = name
182
+ cena << "(#{options[:descripcion]}" if options[:descripcion]
183
+ cena << "(#{options[:porcion]}" if options[:porcion]
184
+ cena << "(#{options[:gramo]}" if options[:gramo]
185
+ cena << "(#{options[:grasa]}" if options[:grasa]
186
+ cena << "(#{options[:proteina]}" if options[:proteina]
187
+ cena << "(#{options[:carbohidratos]}" if options[:carbohidratos]
188
+ cena << "(#{options[:sal]}" if options[:sal]
189
+
190
+ @cena << cena
191
+ end
192
+
193
+
194
+ end
@@ -0,0 +1,126 @@
1
+ class Nutrition
2
+
3
+ include Comparable
4
+ #Atributos de la clase nutrition
5
+ attr_reader :saturadas, :monoinsaturadas, :polinsaturadas, :azucares, :polialcoholes, :almidon, :fibra, :proteinas, :sal, :etiqueta
6
+
7
+ #Función initialize de la clase nutrition
8
+ def initialize(saturadas, monoinsaturadas, polinsaturadas, azucares, polialcoholes, almidon, fibra, proteinas, sal, etiqueta)
9
+ @saturadas, @monoinsaturadas, @polinsaturadas, @azucares, @polialcoholes, @almidon, @fibra, @proteinas, @sal, @etiqueta = saturadas, monoinsaturadas, polinsaturadas, azucares, polialcoholes, almidon, fibra, proteinas, sal, etiqueta
10
+ end
11
+
12
+ #Función que retorna el total de grasas de un producto
13
+ def grasas
14
+ @grasas = @saturadas + @monoinsaturadas + @polinsaturadas
15
+ return @grasas
16
+ end
17
+
18
+ #Función que retorna el total de hidratos de un producto
19
+ def hidratos
20
+ @hidratos = @azucares + @polialcoholes + @almidon
21
+
22
+ return @hidratos
23
+ end
24
+
25
+ #Función que retrona el valor energetico en kilo Julios
26
+ def venergeticokj
27
+ @venergeticokj = @saturadas * 37 + @monoinsaturadas * 37 + @polinsaturadas * 37 + @azucares * 17 + @polialcoholes *10 + @almidon * 17 + @fibra * 8 + @proteinas * 17 + @sal * 25
28
+
29
+ return @venergeticokj
30
+ end
31
+
32
+ #Función que retorna el valor energetico en kilo cal
33
+ def venergeticokcal
34
+ @venergeticokcal = @saturadas * 9 + @monoinsaturadas * 9 + @polinsaturadas * 9 + @azucares * 4 + @polialcoholes * 2.4 + @almidon * 4 + @fibra * 2 + @proteinas * 4 + @sal * 6
35
+ end
36
+
37
+ #Función que retorna el nombre del producto
38
+ def get_nombre
39
+ return @nombre
40
+ end
41
+
42
+ #Función que retorna la cantidad de sal de un producto
43
+ def get_sal
44
+ return @sal
45
+ end
46
+
47
+ #Función que retorna el total de grasas saturadas de un producto
48
+ def get_saturadas
49
+ return @saturadas
50
+ end
51
+
52
+ #Función que retorna el total de grasas azucar de un producto
53
+ def get_azucares
54
+ return @azucares
55
+ end
56
+
57
+ #Función que retorna el total de proteinas saturadas de un producto
58
+ def get_proteinas
59
+ return @proteinas
60
+ end
61
+
62
+ #Función que retorna el indice de referencia energetico de un producto
63
+ def irvenergetico
64
+ @venergeticokj = venergeticokj
65
+ @irvenergetico = (@venergeticokj/8400.to_f) * 100
66
+ @irvenergetico.round(1)
67
+
68
+ return @irvenergetico.round(1)
69
+ end
70
+
71
+ #Función que retorna el indice de referencia de grasas de un producto
72
+ def irgrasas
73
+ @grasas = grasas
74
+ @irgrasas = (@grasas/70.to_f) * 100
75
+ @irgrasas.round(1)
76
+
77
+ return @irgrasas.round(1)
78
+ end
79
+
80
+ #Función que retorna el indice de referencia de grsasas saturadas de un producto
81
+ def irsaturadas
82
+ @irsaturadas = (@saturadas/20.to_f) * 100
83
+ @irsaturadas.round(1)
84
+
85
+ return @irsaturadas.round(1)
86
+ end
87
+
88
+ #Función que retorna el indice de referencia de hidratos de un producto
89
+ def irhidratos
90
+ @hidratos = hidratos
91
+ @irhidratos = (@hidratos/260.to_f) * 100
92
+ @irhidratos.round(1)
93
+
94
+ return @irhidratos.round(1)
95
+ end
96
+
97
+ #Función que retorna el indice de referencia de azucares de un producto
98
+ def irazucares
99
+ @irazucares = (@azucares/90.to_f) * 100
100
+ @irazucares.round(1)
101
+
102
+ return @irazucares.round(1)
103
+ end
104
+
105
+ #Función que retorna el indice de referencia de proteinas de un producto
106
+ def irproteinas
107
+ @irproteinas = (@proteinas/50.to_f) * 100
108
+ @irproteinas.round(1)
109
+
110
+ return @irproteinas.round(1)
111
+ end
112
+
113
+ #Función que retorna el indice de referencia de sal de un producto
114
+ def irsal
115
+ @irsal = (@sal/6.to_f) * 100
116
+ @irsal.round(1)
117
+
118
+ return @irsal.round(1)
119
+ end
120
+
121
+ #Función de definicion de comparables
122
+ def <=> (other)
123
+ venergeticokj <=> other.venergeticokj
124
+ end
125
+
126
+ end
@@ -0,0 +1,3 @@
1
+ module Prct06
2
+ VERSION = "0.1.0"
3
+ end
data/prct06.gemspec ADDED
@@ -0,0 +1,46 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "prct06/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "prct06_alu0100958607"
8
+ spec.version = Prct06::VERSION
9
+ spec.authors = ["Sergio Rodriguez"]
10
+ spec.email = ["alu0100958607@ull.edu.es"]
11
+
12
+ spec.summary = %q{Peactica bundle}
13
+ spec.description = %q{Practica bundle}
14
+ spec.homepage = "https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100958607.git"
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"] = "://github.com/ULL-ESIT-LPP-1819/tdd-alu0100958607.git"
21
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
22
+
23
+ spec.metadata["homepage_uri"] = spec.homepage
24
+ spec.metadata["source_code_uri"] = "https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100958607.git"
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 "coveralls"
46
+ end
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prct06_alu0100958607
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sergio Rodriguez
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: 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: Practica bundle
112
+ email:
113
+ - alu0100958607@ull.edu.es
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".Rakefile.swp"
119
+ - ".coveralls.yml"
120
+ - ".gitignore"
121
+ - ".rspec"
122
+ - ".travis.yml"
123
+ - CODE_OF_CONDUCT.md
124
+ - Gemfile
125
+ - Gemfile.lock
126
+ - Guardfile
127
+ - LICENSE.txt
128
+ - README.md
129
+ - Rakefile
130
+ - bin/console
131
+ - bin/setup
132
+ - lib/prct06.rb
133
+ - lib/prct06/.array.rb.swp
134
+ - lib/prct06/.list.rb.swp
135
+ - lib/prct06/antro.rb
136
+ - lib/prct06/array.rb
137
+ - lib/prct06/guy.rb
138
+ - lib/prct06/list.rb
139
+ - lib/prct06/menu.rb
140
+ - lib/prct06/nutrition.rb
141
+ - lib/prct06/version.rb
142
+ - prct06.gemspec
143
+ homepage: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100958607.git
144
+ licenses:
145
+ - MIT
146
+ metadata:
147
+ allowed_push_host: https://rubygems.org
148
+ homepage_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100958607.git
149
+ source_code_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100958607.git
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 2.7.7
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: Peactica bundle
170
+ test_files: []