menu_juli 0.1.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
+ SHA256:
3
+ metadata.gz: 07a74c4a6941ad44c705e5073139cc268c642230ef30e8f96634e0458e60f80f
4
+ data.tar.gz: bdd83759201977e3af72e4d97c2465bad635bdd159fc36dd950282a8804e119a
5
+ SHA512:
6
+ metadata.gz: b9e20dfc412f0c5b3027048b4b1765bdcb4c0eb4d071b9b1d3ec68137f41b0ee0a548c9af6178e6f6691769f2cbad753b398e31d6981c55f0de1a813b90b6fcd
7
+ data.tar.gz: 5fa3f775c40672feb0faf644188740aaf105629089c8a35f69da27e1d41f7a1f386807e4e70f90bc038b030d7ddbbf745decbcd1979ad9c7fb6d2dbc2a85f0ed
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,9 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+
8
+ before_install: gem install bundler -v 1.17.1
9
+
data/Gemfile ADDED
@@ -0,0 +1,8 @@
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
+ gem 'yard'
7
+ gem 'coveralls', require: false
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,97 @@
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.8.22)
11
+ json (>= 1.8, < 3)
12
+ simplecov (~> 0.16.1)
13
+ term-ansicolor (~> 1.3)
14
+ thor (~> 0.19.4)
15
+ tins (~> 1.6)
16
+ diff-lcs (1.3)
17
+ docile (1.3.1)
18
+ ffi (1.9.25)
19
+ formatador (0.2.5)
20
+ guard (2.15.0)
21
+ formatador (>= 0.2.4)
22
+ listen (>= 2.7, < 4.0)
23
+ lumberjack (>= 1.0.12, < 2.0)
24
+ nenv (~> 0.1)
25
+ notiffany (~> 0.0)
26
+ pry (>= 0.9.12)
27
+ shellany (~> 0.0)
28
+ thor (>= 0.18.1)
29
+ guard-bundler (2.1.0)
30
+ bundler (~> 1.0)
31
+ guard (~> 2.2)
32
+ guard-compat (~> 1.1)
33
+ guard-compat (1.2.1)
34
+ guard-rspec (4.7.3)
35
+ guard (~> 2.1)
36
+ guard-compat (~> 1.1)
37
+ rspec (>= 2.99.0, < 4.0)
38
+ json (2.1.0)
39
+ listen (3.1.5)
40
+ rb-fsevent (~> 0.9, >= 0.9.4)
41
+ rb-inotify (~> 0.9, >= 0.9.7)
42
+ ruby_dep (~> 1.2)
43
+ lumberjack (1.0.13)
44
+ method_source (0.9.2)
45
+ nenv (0.3.0)
46
+ notiffany (0.1.1)
47
+ nenv (~> 0.1)
48
+ shellany (~> 0.0)
49
+ pry (0.12.2)
50
+ coderay (~> 1.1.0)
51
+ method_source (~> 0.9.0)
52
+ rake (10.5.0)
53
+ rb-fsevent (0.10.3)
54
+ rb-inotify (0.9.10)
55
+ ffi (>= 0.5.0, < 2)
56
+ rspec (3.8.0)
57
+ rspec-core (~> 3.8.0)
58
+ rspec-expectations (~> 3.8.0)
59
+ rspec-mocks (~> 3.8.0)
60
+ rspec-core (3.8.0)
61
+ rspec-support (~> 3.8.0)
62
+ rspec-expectations (3.8.2)
63
+ diff-lcs (>= 1.2.0, < 2.0)
64
+ rspec-support (~> 3.8.0)
65
+ rspec-mocks (3.8.0)
66
+ diff-lcs (>= 1.2.0, < 2.0)
67
+ rspec-support (~> 3.8.0)
68
+ rspec-support (3.8.0)
69
+ ruby_dep (1.5.0)
70
+ shellany (0.0.1)
71
+ simplecov (0.16.1)
72
+ docile (~> 1.1)
73
+ json (>= 1.8, < 3)
74
+ simplecov-html (~> 0.10.0)
75
+ simplecov-html (0.10.2)
76
+ term-ansicolor (1.7.0)
77
+ tins (~> 1.0)
78
+ thor (0.19.4)
79
+ tins (1.20.2)
80
+ yard (0.9.16)
81
+
82
+ PLATFORMS
83
+ ruby
84
+
85
+ DEPENDENCIES
86
+ bundler (~> 1.17)
87
+ coveralls
88
+ guard
89
+ guard-bundler
90
+ guard-rspec
91
+ prct06!
92
+ rake (~> 10.0)
93
+ rspec (~> 3.0)
94
+ yard
95
+
96
+ BUNDLED WITH
97
+ 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/README.md ADDED
@@ -0,0 +1,37 @@
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/tdd-alu0101282749/prct06.
36
+
37
+ [![Coverage Status](https://coveralls.io/repos/github/ULL-ESIT-LPP-1819/tdd-alu0101282749/badge.svg?branch=master)](https://coveralls.io/github/ULL-ESIT-LPP-1819/tdd-alu0101282749?branch=master)
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "yard"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
8
+
9
+ desc "Ejecutar las espectativas de la clase Point"
10
+ task :spec do
11
+ sh "rspec -I. spec/prct06_spec.rb"
12
+ end
13
+
14
+ desc "Ejecutar con documentacion"
15
+ task :doc do
16
+ sh "rspec -I. spec/prct06_spec.rb --format documentation"
17
+ end
18
+
19
+ YARD::Rake::YardocTask.new do |t|
20
+ t.files = ['lib/**/*.rb'] # optional
21
+ t.options = ['--any', '--extra', '--opts'] # optional
22
+ t.stats_options = ['--list-undoc'] # optional
23
+ end
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
@@ -0,0 +1,55 @@
1
+ class Array
2
+
3
+
4
+
5
+ def fors
6
+ sorted = [self[0]]
7
+ for i in (1...self.size)
8
+ act = self[i]
9
+ for j in (0..sorted.size)
10
+ if (j == sorted.size)
11
+ sorted.push(act)
12
+ elsif (act.for_helper < sorted[j].for_helper)
13
+ sorted.insert(j, act)
14
+ break
15
+ end
16
+ end
17
+ end
18
+ return sorted
19
+ end
20
+
21
+ def eachs
22
+ sorted = [self[0]]
23
+ self.each_with_index do |x, pos_x|
24
+ if (pos_x != 0)
25
+ sorted.each_with_index do |y, pos_y|
26
+ if (pos_y == sorted.size-1)
27
+ if (x.each_helper < y.each_helper)
28
+ sorted.insert(pos_y, x)
29
+ break
30
+ else
31
+ sorted.push(x)
32
+ break
33
+ end
34
+ elsif (x.each_helper < y.each_helper)
35
+ sorted.insert(pos_y, x)
36
+ break
37
+ end
38
+ end
39
+ end
40
+ end
41
+ return sorted
42
+ end
43
+
44
+ def for_helper
45
+ sum = 0
46
+ for i in (0...self.size)
47
+ sum += self[i].energy
48
+ end
49
+ return sum
50
+ end
51
+
52
+ def each_helper
53
+ return self.collect{|food| food.energy;}.reduce(:+).round(2)
54
+ end
55
+ end
@@ -0,0 +1,89 @@
1
+ #
2
+ # Diet Object to see if a persins gets enough nutrients
3
+ #
4
+ # @author roro
5
+ #
6
+
7
+ class Diet
8
+
9
+ #getter and setter
10
+ attr_accessor :food_energy, :gasto_energetico_total
11
+ include Comparable
12
+
13
+ #
14
+ # Initialize
15
+ # @peso_teorico_ideal [float] [Ideal weight. Calculation formula: ((anthropometric.height - 150) * 0.75 + 50)]
16
+ # @gasto_energetico_basal [float] [Basic energy consumption. Calculation formula: ((10 * anthropometric.weight) + (6.25 * anthropometric.height) - (5 * anthropometric.age) + ((anthropometric.sex==1)? -161 : 5))]
17
+ # @efecto_termogeno [float] [Termogenetic energy consumption. Calculation formula: (@gasto_energetico_basal * 0.1)]
18
+ # @factor_actividad_fisica [float] [A factor to calculate energy consumption depending on the intensity of the activity your doing]
19
+ # @gasto_actividad_fisica [float] [Energy consumption during activity. Calculation formula: (@gasto_energetico_basal * @factor_actividad_fisica)]
20
+ # @gasto_energetico_total [float] [Total Energy consumption. Calculation formula: (@gasto_energetico_basal * @efecto_termogeno + @gasto_actividad_fisica)]
21
+ # @food [array[Nutri]] [A list of food an anthropometric ate]
22
+ #
23
+ # @return [nil] [nothing]
24
+ def initialize(anthropometric)
25
+ @peso_teorico_ideal = (anthropometric.height - 150) * 0.75 + 50
26
+ @gasto_energetico_basal = (10 * anthropometric.weight) + (6.25 * anthropometric.height) - (5 * anthropometric.age) + ((anthropometric.sex==1)? -161 : 5)
27
+ @efecto_termogeno = @gasto_energetico_basal * 0.1
28
+ @factor_actividad_fisica = 0.0
29
+ @gasto_actividad_fisica = @gasto_energetico_basal * @factor_actividad_fisica
30
+ @gasto_energetico_total = @gasto_energetico_basal * @efecto_termogeno + @gasto_actividad_fisica
31
+ @food = Liste.new()
32
+ @food_energy = 0.0
33
+ end
34
+
35
+ #
36
+ # Eat function to include a food the Anthropometric has eaten.
37
+ # @param item [Nutri] [Food Item which was eaten]
38
+ #
39
+ # @return nil [Returns Nothing]
40
+ def eat(it)
41
+ @food.push(it)
42
+ @food_energy = @food.reduce(0) { |sum, obj| sum + obj.energy }
43
+ end
44
+
45
+ #
46
+ # Sport function to change the factor of the physical activity
47
+ # @param intensity [int OR string] [Physical activity level]
48
+ #
49
+ # @return nil [Returns Nothing]
50
+ def sport(intensity)
51
+
52
+ if intensity == 0 || intensity == "reposo"
53
+ @factor_actividad_fisica = 0.0
54
+ elsif intensity == 1 || intensity == "ligera"
55
+ @factor_actividad_fisica = 0.12
56
+ elsif intensity == 2 || intensity == "moderada"
57
+ @factor_actividad_fisica = 0.27
58
+ elsif intensity == 3 || intensity == "intensa"
59
+ @factor_actividad_fisica = 0.54
60
+ else
61
+ puts "Input doesn't make sence!"
62
+ end
63
+ @gasto_actividad_fisica = @gasto_energetico_basal * @factor_actividad_fisica
64
+ @gasto_energetico_total = @gasto_energetico_basal * @efecto_termogeno + @gasto_actividad_fisica
65
+ end
66
+
67
+ #
68
+ # Analize function Analizes all the data and calculates, wheater the consumed food was enough or even too much.
69
+ #
70
+ # @return [string] [Returns a nice readeable output with the evaluated data and the result.]
71
+ def analize()
72
+ difference = @gasto_energetico_total - @food_energy
73
+ puts "Consumed Energy:\t#{@food_energy.round(2)}\nBurned Energy:\t\t#{@gasto_energetico_total.round(2)}\n\n"
74
+ if difference.abs <= @gasto_energetico_total * 0.1
75
+ puts "La cantidad de la alimentación es suficiente para cubrir las exigencias calóricas del organismo y mantiene el equilibrio de su balance.\n Difference: #{difference.round(2)}"
76
+ elsif @food_energy < @gasto_energetico_total
77
+ puts "La cantidad de la alimentación no es suficiente para cubrir las exigencias calóricas del organismo.\nTomaste #{difference.round(2)}kcal/g muy poco."
78
+ elsif @food_energy > @gasto_energetico_total
79
+ puts "Ha consumido demasiado calóricas. No mantiene el equilibrio de su balance.\nTomaste #{difference.round(2)}kcal/g demasiado."
80
+ else puts "Strange ERROR"
81
+ end
82
+ end
83
+
84
+ def <=> (other)
85
+ return nil unless other.is_a?Diet
86
+ gasto_energetico_total <=> other.gasto_energetico_total
87
+ end
88
+
89
+ end
@@ -0,0 +1,222 @@
1
+ #
2
+ # Human Object with very basic data.
3
+ #
4
+ # @author roro
5
+ #
6
+ class Human
7
+
8
+ #
9
+ # Includes thge VIModule Comparable to be able to compare.
10
+ #
11
+ # @author notME
12
+ #
13
+ include Comparable
14
+
15
+ #getter and setter
16
+ attr_accessor :name, :surname, :sex, :age
17
+
18
+ #
19
+ # [Sets how and what to compare]
20
+ # @param other [object] [Person object]
21
+ #
22
+ # @return [bool] [True or False depending whether the comparison is true or not.]
23
+ def <=>(other)
24
+ @name <=> other.name
25
+ end
26
+
27
+ #
28
+ # Initialize
29
+ # @param name [char] [name ]
30
+ # @param surname [char] [surname]
31
+ # @param sex [inr] [sex: 0= male, 1=female]
32
+ # @param age [int] [age]
33
+ #
34
+ # @return [nil] [nothing]
35
+ def initialize(name, surname, sex, age)
36
+ @name, @surname, @sex, @age = name, surname, sex, age
37
+ end
38
+
39
+
40
+ #
41
+ # Returns a string containing Name and Surname of a Human
42
+ #
43
+ # @return [char] [Name and Surname as string.]
44
+ def to_s
45
+ "#{@name} #{@surname}"
46
+ end
47
+
48
+ #
49
+ # Returns a string containing Name Human
50
+ #
51
+ # @return [char] [Name as string.]
52
+ def name_to_s
53
+ "Name: #{@name}\n"
54
+ end
55
+
56
+ #
57
+ # Returns a string containing Surname of a Human
58
+ #
59
+ # @return [char] [Surname as string.]
60
+ def surname_to_s
61
+ "Surname: #{@surname}\n"
62
+ end
63
+
64
+ #
65
+ # Returns a string containing Sex of a Human
66
+ #
67
+ # @return [char] [Sex as string.]
68
+ def sex_to_s
69
+ "Sex: #{@sex}\n"
70
+ end
71
+
72
+ #
73
+ # Returns a string containing Age of a Human
74
+ #
75
+ # @return [char] [Age as string.]
76
+ def age_to_s
77
+ "Age: #{@age}\n"
78
+ end
79
+ end
80
+
81
+
82
+ #
83
+ # Anthropometric Object is a Child class from the Human with extented data sobre la salud.
84
+ #
85
+ # @author [roro]
86
+ #
87
+ class Anthropometric < Human
88
+ #getter and setter all in one
89
+ attr_accessor :name, :surname, :sex, :age, :height, :weight
90
+
91
+ #
92
+ # Initialize
93
+ # @param name [char] [name ]
94
+ # @param surname [char] [surname]
95
+ # @param sex [inr] [sex: 0= male, 1=female]
96
+ # @param age [int] [age]
97
+ # @param height [float] [height]
98
+ # @param weight [float] [weight]
99
+ # @param waist [list] [waist]
100
+ # @param hip [list] [hip]
101
+ # @param triceps [list] [triceps]
102
+ # @param bicipital [list] [bicipital]
103
+ # @param subscapular [list] [subscapular]
104
+ # @param suprailiac [list] [suprailiac]
105
+ # @param arm [list] [arm]
106
+ #
107
+ # @return [nil] [nothing]
108
+ def initialize(name, surname, sex, age, height, weight, waist, hip, triceps, bicipital, subscapular, suprailiac, arm)
109
+ super(name, surname, sex, age)
110
+ @height, @weight, @waist, @hip, @triceps, @bicipital, @subscapular, @suprailiac, @arm = height, weight, waist, hip, triceps, bicipital, subscapular, suprailiac, arm
111
+ end
112
+
113
+ #
114
+ # Returns a string containing Height of an Anthropometric
115
+ #
116
+ # @return [char] [Height as string.]
117
+ def height_to_s
118
+ "Height: #{@height}\n"
119
+ end
120
+
121
+ #
122
+ # Returns a string containing Weight of an Anthropometric
123
+ #
124
+ # @return [char] [Weight as string.]
125
+ def weight_to_s
126
+ "Weight: #{@weight}\n"
127
+ end
128
+
129
+ #
130
+ # Returns a string containing Waist of an Anthropometric
131
+ #
132
+ # @return [char] [Waist as string.]
133
+ def waist_to_s
134
+ return uni_med(@waist)
135
+ end
136
+
137
+ #
138
+ # Returns a string containing Hip of an Anthropometric
139
+ #
140
+ # @return [char] [Hip as string.]
141
+ def hip_to_s
142
+ return uni_med(@hip)
143
+ end
144
+
145
+ #
146
+ # Returns a string containing Triceps of an Anthropometric
147
+ #
148
+ # @return [char] [Triceps as string.]
149
+ def triceps_to_s
150
+ return uni_med(@triceps)
151
+ end
152
+
153
+ #
154
+ # Returns a string containing Biceps of an Anthropometric
155
+ #
156
+ # @return [char] [Biceps as string.]
157
+ def biceps_to_s
158
+ return uni_med(@bicipital)
159
+ end
160
+
161
+ #
162
+ # Returns a string containing Subcapular of an Anthropometric
163
+ #
164
+ # @return [char] [Subcapular as string.]
165
+ def subscapular_to_s
166
+ return uni_med(@subscapular)
167
+ end
168
+
169
+ #
170
+ # Returns a string containing Suprailiac of an Anthropometric
171
+ #
172
+ # @return [char] [Suprailiac as string.]
173
+ def suprailiac_to_s
174
+ return uni_med(@suprailiac)
175
+ end
176
+
177
+ #
178
+ # Returns a string containing Triceps of an Anthropometric
179
+ #
180
+ # @return [char] [Triceps as string.]
181
+ def arm_to_s
182
+ return uni_med(@arm)
183
+ end
184
+
185
+ #
186
+ # Universal Median Calculator
187
+ # @param li [list] [List of Numbers of which the median should be calculated]
188
+ #
189
+ # @return [float] [Returns Median]
190
+ def uni_med(li)
191
+ sum, i = 0, 0
192
+ while(i < li.length)
193
+ sum += li[i]
194
+ i += 1
195
+ end
196
+ return (sum/li.length).round(2)
197
+ end
198
+
199
+ #
200
+ # Returns the calculated IMC of an Anthropometric
201
+ #
202
+ # @return [char] [IMC of Anthropometric]
203
+ def imc
204
+ return (@weight/@height**2).round(2)
205
+ end
206
+
207
+ #
208
+ # Returns the calculated RCC of an Anthropometric
209
+ #
210
+ # @return [char] [RCC of Anthropometric]
211
+ def rcc
212
+ return (waist_to_s()/hip_to_s).round(2)
213
+ end
214
+
215
+ #
216
+ # Returns the calculated percentage of fat of an Anthropometric
217
+ #
218
+ # @return [char] [Percentage of fat of an Anthropometric]
219
+ def porc_fat
220
+ return (1.2 * imc + 0.23 * @age - 10.8 * @sex -5.4).round(2)
221
+ end
222
+ end
@@ -0,0 +1,164 @@
1
+ #
2
+ # Doubly Linked List
3
+ # Enumerable functions included
4
+ #
5
+ # @author [roro]
6
+ #
7
+ class Liste
8
+ include Enumerable
9
+
10
+ Node = Struct.new(:value, :next, :prev)
11
+ attr_reader :size, :head, :tail
12
+
13
+ #
14
+ # Initialize
15
+ # Initializes all to nil
16
+ # @return [nil] [nothing]
17
+ def initialize()
18
+ @head = nil
19
+ @tail = nil
20
+ @size = 0
21
+ end
22
+
23
+ #
24
+ # Each Method, necessarie for the enumeration
25
+ #
26
+ # @return [obj.value] [gives back the value of the actual node]
27
+ def each()
28
+ act = @head
29
+ while act != nil
30
+ yield act.value
31
+ act = act.next
32
+ end
33
+ end
34
+
35
+ #
36
+ # Pushes a new Object at the end of the list.
37
+ # @param obj [object] [Object that should be placed at the end of the list.]
38
+ #
39
+ # @return [string] [Returns the String of the Object]
40
+ def push(obj)
41
+ a = Node.new(obj, nil, @tail)
42
+ if size > 0
43
+ @tail.next = a
44
+ else
45
+ @head = a
46
+ end
47
+ @tail = a
48
+ @size += 1
49
+ return a.value.to_s
50
+ end
51
+
52
+ def pushb(obj)
53
+ a = Node.new(obj, @head, nil)
54
+ if size > 0
55
+ @head.prev = a
56
+ else
57
+ @tail = a
58
+ end
59
+ @head = a
60
+ @size += 1
61
+ return a.value.to_s
62
+ end
63
+
64
+ #
65
+ # Pops the last Element of the list and prints it via the to_s method.
66
+ #
67
+ # @return [string] [Returns the String of the Object]
68
+ def pop()
69
+ if size > 0
70
+ a = @tail.value
71
+ @size -= 1
72
+ @tail = @tail.prev
73
+ if size > 0
74
+ @tail.next = nil
75
+ else
76
+ @head = nil
77
+ end
78
+ else
79
+ puts "No elements"
80
+ end
81
+ return a.to_s
82
+ end
83
+
84
+ def popb()
85
+ if size > 0
86
+ a = @head.value
87
+ @size -= 1
88
+ @head = @head.next
89
+ if size > 0
90
+ @head.prev = nil
91
+ else
92
+ @head = nil
93
+ end
94
+ else
95
+ puts "No elements"
96
+ end
97
+ return a.to_s
98
+ end
99
+
100
+ def pushn(ar)
101
+ ar.each do |i|
102
+ push(i)
103
+ end
104
+ end
105
+ def pushbn(ar)
106
+ ar.each do |i|
107
+ pushb(i)
108
+ end
109
+ end
110
+ def popn(i)
111
+ while @size > 0 && i > 0 do
112
+ pop()
113
+ end
114
+ end
115
+ def popbn(i)
116
+ while @size > 0 && i > 0 do
117
+ popb()
118
+ end
119
+ end
120
+
121
+ # Tarea 3 - for
122
+ def fors
123
+ sorted = [@head.value]
124
+ act = @head
125
+ for i in (1...@size)
126
+ act = act.next
127
+ for j in (0..sorted.size)
128
+ if (j == sorted.size)
129
+ sorted.push(act.value)
130
+ elsif (act.value < sorted[j])
131
+ sorted.insert(j, act.value)
132
+ break
133
+ end
134
+ end
135
+ end
136
+ return sorted
137
+ end
138
+
139
+ # Tarea 4 - each
140
+ def eachs
141
+ sorted = [@head.value]
142
+ self.each_with_index do |x, pos_x|
143
+ if (pos_x != 0)
144
+ sorted.each_with_index do |y, pos_y|
145
+ if (pos_y == sorted.size - 1)
146
+ if (x < y)
147
+ sorted.insert(pos_y, x)
148
+ break
149
+ else
150
+ sorted.push(x)
151
+ break
152
+ end
153
+ elsif (x < y)
154
+ sorted.insert(pos_y, x)
155
+ break
156
+ end
157
+ end
158
+ end
159
+ end
160
+ return sorted
161
+ end
162
+
163
+
164
+ end
@@ -0,0 +1,99 @@
1
+ #
2
+ # [Class to representate diets menus of day and week]
3
+ #
4
+ # @author [julian]
5
+ #
6
+ class Menu
7
+ attr_accessor :day, :title
8
+
9
+ #
10
+ # [initialize]
11
+ # @param day [type] [description]
12
+ # @param &block [type] [description]
13
+ #
14
+ # @return [type] [description]
15
+ def initialize(day, &block)
16
+ @day = day
17
+ @title = title
18
+ @breakfast, @lunch, @dinner = [], [], []
19
+ @table = [" ", "grasas carbohidratos", "proteínas", "fibra", "sal", "valor energético"]
20
+ @tot_energy = 0
21
+ if block_given?
22
+ if block.arity == 1
23
+ yield self
24
+ else
25
+ instance_eval(&block)
26
+ end
27
+ end
28
+ end
29
+
30
+ def titulo(titulo)
31
+ @title = titulo
32
+ end
33
+
34
+ def ingesta(properties = {})
35
+ @min = properties[:min] ? properties[:min] : "unknown"
36
+ @max = properties[:max] ? properties[:max] : "unknown"
37
+ end
38
+
39
+ def desayuno(properties = {})
40
+ @breakfast.push(food(properties))
41
+ end
42
+
43
+ def almuerzo(properties = {})
44
+ @lunch.push(food(properties))
45
+ end
46
+
47
+ def cena(properties = {})
48
+ @dinner.push(food(properties))
49
+ end
50
+
51
+ def food(properties)
52
+ food = Array.new(7)
53
+ food[0] = properties[:descripcion] ? "\"#{properties[:descripcion]}\"" : "unknown"
54
+ food[0] = food[0].length > 23 ? "#{food[0][0,20]}..\"" : food[0]
55
+ food[1] = properties[:grasas] ? properties[:grasas] : 0.0
56
+ food[2] = properties[:carbohidratos] ? properties[:carbohidratos] : 0.0
57
+ food[3] = properties[:proteinas] ? properties[:proteinas] : 0.0
58
+ food[4] = properties[:fibra] ? properties[:fibra] : 0.0
59
+ food[5] = properties[:sal] ? properties[:sal] : 0.0
60
+ food[6] = (food[1] * 36 + food[2] * 17 + food[3] * 17 + food[5] * 25).round(2)
61
+ @tot_energy += food[6]
62
+ return food
63
+ end
64
+
65
+ #
66
+ # [turns the given list into a formated string]
67
+ # @param liste [list] [list of menu]
68
+ #
69
+ # @return [string] [readable string]
70
+ def to_s_formatter(liste)
71
+ to_ret = ""
72
+ liste.each do |obj|
73
+ to_ret << "#{obj[0]}\t"
74
+ if obj[0].length < 16
75
+ to_ret << "\t"
76
+ if obj[0].length < 8
77
+ to_ret << "\t"
78
+ end
79
+ end
80
+ to_ret << "#{obj[1]}\t#{obj[2]}\t\t#{obj[3]}\t\t#{obj[4]}\t#{obj[5]}\t#{obj[6]}\n"
81
+ end
82
+ return to_ret
83
+ end
84
+
85
+ #
86
+ # [method to represent the created obj as a string, readable for humans]
87
+ #
88
+ # @return [string] [obj as a string, readable]
89
+ def to_s()
90
+ output = "#{@day}\t\t\t\t\tComposición nutricional\n"
91
+ output << "=" * 100 + "\n"
92
+ output << "\t\t\tgrasas\tcarbohidratos\tproteínas\tfibra\tsal\tvalor energético\n"
93
+ output << "Desayuno\n" + to_s_formatter(@breakfast) + "\n"
94
+ output << "Almuerzo\n" + to_s_formatter(@lunch) + "\n"
95
+ output << "Cena\n" + to_s_formatter(@dinner)
96
+ output << "Valor energético total #{@tot_energy}"
97
+ output
98
+ end
99
+ end
@@ -0,0 +1,127 @@
1
+ #
2
+ # Manages all the informations a normal etiquett contains.
3
+ #
4
+ # @author [roro]
5
+
6
+ class Nutri
7
+ #
8
+ # Include trhe very important Comparable to be able to compare
9
+ #
10
+ # @author NotME
11
+ include Comparable
12
+
13
+ attr_reader :name, :fat, :sfats, :hydrates, :sugar, :protein, :salt, :energy
14
+
15
+
16
+ #
17
+ # Defines wich value should be compared
18
+ # @param other [object] [another object]
19
+ #
20
+ # @return [bool] [True or False whether the compatrison is correct or not.]
21
+ def <=>(other)
22
+ @name <=> other.name
23
+ end
24
+
25
+
26
+ #
27
+ # [initialize the obj]
28
+ # @param name [string] [Name]
29
+ # @param fat [int] [Fat value]
30
+ # @param sfats [int] [Saturates Fat value]
31
+ # @param hydrates [int] [Hydrates value]
32
+ # @param sugar [int] [Sugar value]
33
+ # @param protein [int] [Protein value]
34
+ # @param salt [int] [Salt Value]
35
+ #
36
+ # @return [nil] [there is nothing to return]
37
+ def initialize(name, fat, sfats, hydrates, sugar, protein, salt)
38
+ @name, @fat, @sfats, @hydrates, @sugar, @protein, @salt = name, fat, sfats, hydrates, sugar, protein, salt
39
+ @energy = 0.0
40
+ senergy()
41
+ end
42
+
43
+ #
44
+ # Prints name as a string.
45
+ #
46
+ # @return [string] [name as a string]
47
+ def sname
48
+ "#{@name}"
49
+ end
50
+
51
+ #
52
+ # Prints fat as a string.
53
+ #
54
+ # @return [string] [fat as a string]
55
+ def sfat
56
+ "#{@fat}"
57
+ end
58
+
59
+ #
60
+ # Prints sfats as a string.
61
+ #
62
+ # @return [string] [sfats as a string]
63
+ def ssfats
64
+ "#{@sfats}"
65
+ end
66
+
67
+ #
68
+ # Prints hydrates as a string.
69
+ #
70
+ # @return [string] [hydrates as a string]
71
+ def shydrates
72
+ "#{@hydrates}"
73
+ end
74
+
75
+ #
76
+ # Prints sugar as a string.
77
+ #
78
+ # @return [string] [sugar as a string]
79
+ def ssugar
80
+ "#{@sugar}"
81
+ end
82
+
83
+ #
84
+ # Prints protein as a string.
85
+ #
86
+ # @return [string] [protein as a string]
87
+ def sprotein
88
+ "#{@protein}"
89
+ end
90
+
91
+ #
92
+ # Prints salt as a string.
93
+ #
94
+ # @return [string] [salt as a string]
95
+ def ssalt
96
+ "#{@salt}"
97
+ end
98
+
99
+ #
100
+ # Prints the whole etiquetta as a string.
101
+ #
102
+ # @return [string] [Etiquetta as a string]
103
+ def to_s
104
+ return "Name: \t\t#{@name}\nfat: \t\t#{@fat}\nsat.fats: \t#{@sfats}\nhydrates: \t#{@hydrates}\nsugar: \t\t#{@sugar}\nprotein: \t#{@protein}\nsalt: \t\t#{@salt}\n"
105
+ end
106
+
107
+ #
108
+ # Prints the calculated energy as a string.
109
+ #
110
+ # @return [string] [Energy as a string]
111
+ def senergy
112
+ v1 = [@fat, @hydrates, @protein, @salt]
113
+ v2 = [37, 17, 17, 25]
114
+ v3 = [9, 4, 4, 6]
115
+
116
+ s1 = 0
117
+ s2 = 0
118
+ i = 0
119
+ while (i < v1.length)
120
+ s1 += v1[i] * v2[i]
121
+ s2 += v1[i] * v3[i]
122
+ i += 1
123
+ end
124
+ @energy = s2
125
+ return "#{s1.round(2)} kJ/g / #{s2.round(2)} kcal/g\n"
126
+ end
127
+ end
@@ -0,0 +1,9 @@
1
+ #
2
+ # Helper-Module module for all the tareas
3
+ #
4
+ # @author [roro]
5
+ #
6
+ class VERSION end
7
+ module Prct06
8
+ VERSION = "0.1.0"
9
+ end
data/lib/prct06.rb ADDED
@@ -0,0 +1,18 @@
1
+ #require "prct06/version"
2
+ require "prct06/nutri"
3
+ require "prct06/list"
4
+ require "prct06/human"
5
+ require "prct06/diet"
6
+ require "prct06/array"
7
+ require "prct06/menu"
8
+
9
+ #
10
+ # Main module for all the tareas
11
+ #
12
+ # @author [roro]
13
+ #
14
+ module Prct06
15
+ class Error < StandardError; end
16
+ end
17
+
18
+
data/prct06.gemspec ADDED
@@ -0,0 +1,45 @@
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 = "menu_juli"
8
+ spec.version = Prct06::VERSION
9
+ spec.authors = ["Julian Herrdum"]
10
+ spec.email = ["alu0101282749@ull.edu.es"]
11
+
12
+ spec.summary = %q{Write a short summary, because RubyGems requires one.}
13
+ spec.description = %q{Write a longer description or delete this line.}
14
+ spec.homepage = "https://rubygems.org"
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 'https://rubygems.org'"
20
+
21
+ # spec.metadata["homepage_uri"] = spec.homepage
22
+ # spec.metadata["source_code_uri"] = "https://rubygems.org"
23
+ # spec.metadata["changelog_uri"] = spec.homepage
24
+ # else
25
+ # raise "RubyGems 2.0 or newer is required to protect against " \
26
+ # "public gem pushes."
27
+ # end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_development_dependency "bundler", "~> 1.17"
39
+ spec.add_development_dependency "rake", "~> 10.0"
40
+ spec.add_development_dependency "rspec", "~> 3.0"
41
+ spec.add_development_dependency "guard"
42
+ spec.add_development_dependency "guard-rspec"
43
+ spec.add_development_dependency "guard-bundler"
44
+ spec.metadata["yard.run"] = "yri" # use "yard" to build full HTML docs.
45
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: menu_juli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Julian Herrdum
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-01-08 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
+ description: Write a longer description or delete this line.
98
+ email:
99
+ - alu0101282749@ull.edu.es
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".coveralls.yml"
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - Gemfile.lock
110
+ - Guardfile
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/setup
115
+ - lib/prct06.rb
116
+ - lib/prct06/array.rb
117
+ - lib/prct06/diet.rb
118
+ - lib/prct06/human.rb
119
+ - lib/prct06/list.rb
120
+ - lib/prct06/menu.rb
121
+ - lib/prct06/nutri.rb
122
+ - lib/prct06/version.rb
123
+ - prct06.gemspec
124
+ homepage: https://rubygems.org
125
+ licenses: []
126
+ metadata:
127
+ yard.run: yri
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.7.7
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Write a short summary, because RubyGems requires one.
148
+ test_files: []