alu0101028163 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +2 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +95 -0
- data/Guardfile +82 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/practica6.rb +14 -0
- data/lib/practica6/etiqueta.rb +195 -0
- data/lib/practica6/list.rb +178 -0
- data/lib/practica6/menu_dietetico.rb +246 -0
- data/lib/practica6/paciente.rb +13 -0
- data/lib/practica6/paciente_obeso.rb +55 -0
- data/lib/practica6/persona.rb +31 -0
- data/lib/practica6/pruebas_menu.rb +208 -0
- data/lib/practica6/registro.rb +167 -0
- data/lib/practica6/version.rb +3 -0
- data/practica6.gemspec +46 -0
- metadata +170 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e849fbbd463505c6284bebb84157d6532cbec6f8
|
4
|
+
data.tar.gz: 9efddeadc85de7eb13a5d4c5a871e7152a7c70a1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7c50208d680ec01c1f64362e903a6da65ccf09f382f7e755b9cff100749b7fa942597fd37c88edc323c137adcf421c8e267f1b9b3cdaac789118d116fe25aac7
|
7
|
+
data.tar.gz: e925d9f27b0e29b23fb79beb28136f2acaa89a9a7af17b6005b3c20a5b50a67af92289fd8b5ef85f9d1c0cd4252e06e44ed7cd212b76d085a92774be54b5b13c
|
data/.coveralls.yml
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 alu0101028163@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
data/Gemfile.lock
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
practica6 (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
|
+
|
81
|
+
PLATFORMS
|
82
|
+
ruby
|
83
|
+
|
84
|
+
DEPENDENCIES
|
85
|
+
bundler (~> 1.17)
|
86
|
+
coveralls
|
87
|
+
guard
|
88
|
+
guard-bundler
|
89
|
+
guard-rspec
|
90
|
+
practica6!
|
91
|
+
rake (~> 10.0)
|
92
|
+
rspec (~> 3.0)
|
93
|
+
|
94
|
+
BUNDLED WITH
|
95
|
+
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.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
guard :bundler do
|
19
|
+
require 'guard/bundler'
|
20
|
+
require 'guard/bundler/verify'
|
21
|
+
helper = Guard::Bundler::Verify.new
|
22
|
+
|
23
|
+
files = ['Gemfile']
|
24
|
+
files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
|
25
|
+
|
26
|
+
# Assume files are symlinked from somewhere
|
27
|
+
files.each { |file| watch(helper.real_path(file)) }
|
28
|
+
end
|
29
|
+
|
30
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
31
|
+
# rspec may be run, below are examples of the most common uses.
|
32
|
+
# * bundler: 'bundle exec rspec'
|
33
|
+
# * bundler binstubs: 'bin/rspec'
|
34
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
35
|
+
# installed the spring binstubs per the docs)
|
36
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
37
|
+
# * 'just' rspec: 'rspec'
|
38
|
+
|
39
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
40
|
+
require "guard/rspec/dsl"
|
41
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
42
|
+
|
43
|
+
# Feel free to open issues for suggestions and improvements
|
44
|
+
|
45
|
+
# RSpec files
|
46
|
+
rspec = dsl.rspec
|
47
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
48
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
49
|
+
watch(rspec.spec_files)
|
50
|
+
|
51
|
+
# Ruby files
|
52
|
+
ruby = dsl.ruby
|
53
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
54
|
+
|
55
|
+
# Rails files
|
56
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
57
|
+
dsl.watch_spec_files_for(rails.app_files)
|
58
|
+
dsl.watch_spec_files_for(rails.views)
|
59
|
+
|
60
|
+
watch(rails.controllers) do |m|
|
61
|
+
[
|
62
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
63
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
64
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
65
|
+
]
|
66
|
+
end
|
67
|
+
|
68
|
+
# Rails config changes
|
69
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
70
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
71
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
72
|
+
|
73
|
+
# Capybara features specs
|
74
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
75
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
76
|
+
|
77
|
+
# Turnip features and steps
|
78
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
79
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
80
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
81
|
+
end
|
82
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 alu0101028163
|
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
|
+
# Practica6
|
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/practica6`. 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 'practica6'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install practica6
|
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]/practica6. 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 Practica6 project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/practica6/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "practica6"
|
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
data/lib/practica6.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "practica6/version"
|
2
|
+
require "practica6/etiqueta"
|
3
|
+
require "practica6/list"
|
4
|
+
require "practica6/persona"
|
5
|
+
require "practica6/paciente"
|
6
|
+
require "practica6/paciente_obeso"
|
7
|
+
require "practica6/registro"
|
8
|
+
require "practica6/pruebas_menu"
|
9
|
+
require "practica6/menu_dietetico.rb"
|
10
|
+
|
11
|
+
module Practica6
|
12
|
+
class Error < StandardError; end
|
13
|
+
# Your code goes here...
|
14
|
+
end
|
@@ -0,0 +1,195 @@
|
|
1
|
+
class Etiqueta
|
2
|
+
include Comparable
|
3
|
+
attr_reader :valor_energetico, :grasas , :hidratos_carbono, :fibra_alimentaria, :proteinas, :sal, :vitamina, :porciones, :cantidad_porciones, :tamanio_porciones
|
4
|
+
|
5
|
+
# @param [Etiqueta] recibe como parámetro otra instancia de la clase Etiqueta con la que va a compararse
|
6
|
+
# @return [Number] retorna -1,0 o 1.
|
7
|
+
def <=>(etiqueto)
|
8
|
+
@valor_energetico <=> etiqueto.valor_energetico
|
9
|
+
end
|
10
|
+
|
11
|
+
# @param valor_energetico [Array] expresado en kJ y en kCal
|
12
|
+
# @param grasas [Array] donde tenemos las grasas saturadas, monoinsaturadas y poliinsaturadas.
|
13
|
+
# @param hidratos_carbono [Array] donde están contenidos azúcares, polialcoles y el almidón.
|
14
|
+
# @param fibra_alimentaria [Number]
|
15
|
+
# @param proteinas [Number]
|
16
|
+
# @param sal [Number]
|
17
|
+
# @param vitamina [Number]
|
18
|
+
# @param porciones [Bool] indica si el producto viene o no en porciones
|
19
|
+
# @param cantidad_porciones [Number]
|
20
|
+
# @param tamanio_porciones [Number]
|
21
|
+
# @return [Etiqueta] retorna una nueva instancia de Etiqueta.
|
22
|
+
|
23
|
+
def initialize(valor_energetico, grasas, hidratos_carbono, fibra_alimentaria, proteinas, sal, vitamina, porciones , cantidad_porciones, tamanio_porciones)
|
24
|
+
@valor_energetico = valor_energetico
|
25
|
+
@grasas = grasas
|
26
|
+
@hidratos_carbono = hidratos_carbono
|
27
|
+
@fibra_alimentaria = fibra_alimentaria
|
28
|
+
@proteinas = proteinas
|
29
|
+
@sal = sal
|
30
|
+
@vitamina = vitamina
|
31
|
+
@porciones = porciones
|
32
|
+
@cantidad_porciones = cantidad_porciones
|
33
|
+
@tamanio_porciones = tamanio_porciones
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [Number] retorna la suma de las grasas.
|
37
|
+
def total_grasas()
|
38
|
+
sum = 0
|
39
|
+
@grasas.each { |a| sum+= a }
|
40
|
+
sum
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [Number] retorna la suma de los hidratos de carbono.
|
44
|
+
def total_hidratos()
|
45
|
+
sum = 0
|
46
|
+
@hidratos_carbono.each { |a| sum+= a}
|
47
|
+
sum
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [Number] retorna la energía que aportan las grasas saturadas.
|
51
|
+
def energia_g_saturadas()
|
52
|
+
grasas = @grasas
|
53
|
+
energia_total = []
|
54
|
+
energia_total.push((grasas[0] * 37).round(2))
|
55
|
+
energia_total.push((grasas[0] * 9).round(2))
|
56
|
+
energia_total
|
57
|
+
end
|
58
|
+
|
59
|
+
# @return [Number] retorna la energía que aportan las grasas monoinsaturadas.
|
60
|
+
def energia_g_monoinsaturadas()
|
61
|
+
grasas = @grasas
|
62
|
+
energia_total = []
|
63
|
+
energia_total.push((grasas[1] * 37).round(2))
|
64
|
+
energia_total.push((grasas[1] * 9).round(2))
|
65
|
+
energia_total
|
66
|
+
end
|
67
|
+
|
68
|
+
# @return [Number] retorna la energía que aportan las grasas poliinsaturadas.
|
69
|
+
def energia_g_polinsaturadas()
|
70
|
+
grasas = @grasas
|
71
|
+
energia_total = []
|
72
|
+
energia_total.push((grasas[2] * 37).round(2))
|
73
|
+
energia_total.push((grasas[2] * 9).round(2))
|
74
|
+
energia_total
|
75
|
+
end
|
76
|
+
|
77
|
+
# @return [Number] retorna la energía que aportan los azúcares.
|
78
|
+
def energia_azucares()
|
79
|
+
hidratos = @hidratos_carbono
|
80
|
+
energia_total = []
|
81
|
+
energia_total.push((hidratos[0] * 17).round(2))
|
82
|
+
energia_total.push((hidratos[0] * 4).round(2))
|
83
|
+
energia_total
|
84
|
+
end
|
85
|
+
|
86
|
+
# @return [Number] retorna la energía que aportan los polialcoles.
|
87
|
+
def energia_polialcoles()
|
88
|
+
hidratos = @hidratos_carbono
|
89
|
+
energia_total = []
|
90
|
+
energia_total.push((hidratos[1] * 10).round(2))
|
91
|
+
energia_total.push((hidratos[1] * 2.5).round(2))
|
92
|
+
energia_total
|
93
|
+
end
|
94
|
+
|
95
|
+
# @return [Number] retorna la energía que aporta el almidón.
|
96
|
+
def energia_almidon()
|
97
|
+
hidratos = @hidratos_carbono
|
98
|
+
energia_total = []
|
99
|
+
energia_total.push((hidratos[2] * 17).round(2))
|
100
|
+
energia_total.push((hidratos[2] * 4).round(2))
|
101
|
+
energia_total
|
102
|
+
end
|
103
|
+
|
104
|
+
# @return [Number] retorna la energía que aporta la fibra.
|
105
|
+
def energia_fibra()
|
106
|
+
fibra_alimentaria = @fibra_alimentaria
|
107
|
+
energia_total = []
|
108
|
+
energia_total.push((fibra_alimentaria * 8).round(2))
|
109
|
+
energia_total.push((fibra_alimentaria * 2).round(2))
|
110
|
+
energia_total
|
111
|
+
end
|
112
|
+
|
113
|
+
# @return [Number] retorna la energía que aportan las proteínas.
|
114
|
+
def energia_proteinas()
|
115
|
+
proteinas = @proteinas
|
116
|
+
energia_total = []
|
117
|
+
energia_total.push((proteinas * 17).round(2))
|
118
|
+
energia_total.push((proteinas * 4).round(2))
|
119
|
+
energia_total
|
120
|
+
end
|
121
|
+
|
122
|
+
# @return [Number] retorna la energía que aporta la sal.
|
123
|
+
def energia_sal()
|
124
|
+
sal = @sal
|
125
|
+
energia_total = []
|
126
|
+
energia_total.push((sal * 25).round(2))
|
127
|
+
energia_total.push((sal * 6).round(2))
|
128
|
+
energia_total
|
129
|
+
end
|
130
|
+
|
131
|
+
# @return [Number] retorna el valor energético total.
|
132
|
+
def valor_energetico_total()
|
133
|
+
kj = []
|
134
|
+
sum = 0
|
135
|
+
sum += self.energia_g_saturadas()[0]
|
136
|
+
sum += self.energia_g_monoinsaturadas()[0]
|
137
|
+
sum += self.energia_g_polinsaturadas()[0]
|
138
|
+
sum += self.energia_azucares()[0]
|
139
|
+
sum += self.energia_polialcoles()[0]
|
140
|
+
sum += self.energia_almidon()[0]
|
141
|
+
sum += self.energia_fibra()[0]
|
142
|
+
sum += self.energia_proteinas()[0]
|
143
|
+
sum += self.energia_sal()[0]
|
144
|
+
kj.push(sum.round(2))
|
145
|
+
sum = 0
|
146
|
+
sum += self.energia_g_saturadas()[1]
|
147
|
+
sum += self.energia_g_monoinsaturadas()[1]
|
148
|
+
sum += self.energia_g_polinsaturadas()[1]
|
149
|
+
sum += self.energia_azucares()[1]
|
150
|
+
sum += self.energia_polialcoles()[1]
|
151
|
+
sum += self.energia_almidon()[1]
|
152
|
+
sum += self.energia_fibra()[1]
|
153
|
+
sum += self.energia_proteinas()[1]
|
154
|
+
sum += self.energia_sal()[1]
|
155
|
+
kj.push(sum.round(2))
|
156
|
+
kj
|
157
|
+
end
|
158
|
+
|
159
|
+
# @return [String] retorna una cadena con la información de la etiqueta.
|
160
|
+
def to_s
|
161
|
+
s = "Valor energético por 100g o 100ml de producto .... #{@valor_energetico[0]} kcal / #{@valor_energetico[1]} kj
|
162
|
+
Grasas ........ #{total_grasas} gr
|
163
|
+
de las cuales
|
164
|
+
saturadas .......... #{@grasas[0]} gr
|
165
|
+
monoinsaturadas .... #{@grasas[1]} gr
|
166
|
+
polinsaturadas ..... #{@grasas[2]} gr
|
167
|
+
Hidratos ............. #{total_hidratos} gr
|
168
|
+
de los cuales
|
169
|
+
azucares ........... #{@hidratos_carbono[0]} gr
|
170
|
+
polialcoles ........ #{@hidratos_carbono[1]} gr
|
171
|
+
almidon ............ #{@hidratos_carbono[2]} gr
|
172
|
+
Fibra alimentaria .... #{@fibra_alimentaria} gr
|
173
|
+
Proteínas ............ #{@proteinas} gr
|
174
|
+
Sal .................. #{@sal} gr"
|
175
|
+
|
176
|
+
if @porciones == true
|
177
|
+
s << "
|
178
|
+
Cantidad porciones ... #{@cantidad_porciones} uds
|
179
|
+
Tamaño porciones ..... #{@tamanio_porciones} gr"
|
180
|
+
end
|
181
|
+
|
182
|
+
s << "
|
183
|
+
"
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
|
194
|
+
etiqueta_ = Etiqueta.new([2380.24, 572.76], [17.3,10,12], [41.2,4.15,5.12], 3.3 , 2.4, 1.2, 0, true, 1, 25)
|
195
|
+
puts etiqueta_.to_s
|