menus_alu100851236 0.2.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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Guardfile +82 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/menus/LinkedList.rb +131 -0
- data/lib/menus/menu.rb +70 -0
- data/lib/menus/menu_dsl.rb +48 -0
- data/lib/menus/menu_saludable.rb +32 -0
- data/lib/menus/node.rb +1 -0
- data/lib/menus/version.rb +3 -0
- data/lib/menus.rb +10 -0
- data/menus.gemspec +40 -0
- metadata +148 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 45a309c7ae9c8fdbdee266ad8272f06bbd719dfd
|
|
4
|
+
data.tar.gz: 1f899f973bdf09895c77e72028111bb17ce16691
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 015677ce4176256ae105dacc651592f0459aa1825499ba789bc8ce01c78c8153d6f775b94cfb876f82391245da43cce69d2dc5b18d935ccdbe4401bb3b9e2adf
|
|
7
|
+
data.tar.gz: 9cf158ba09c73356b682a4a2743b2b40782f3bfe0b8082230c5f209a7dc05d36b72995ea8ce4dfb143eff9155b82eb6f6cc01e9561d1e9d381c3888194e3f352
|
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 alu0100851236@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/Guardfile
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# A sample Guardfile
|
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
|
3
|
+
|
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
|
5
|
+
# directories %w(app lib config test spec features) \
|
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
|
7
|
+
|
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
|
11
|
+
#
|
|
12
|
+
# $ mkdir config
|
|
13
|
+
# $ mv Guardfile config/
|
|
14
|
+
# $ ln -s config/Guardfile .
|
|
15
|
+
#
|
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
|
17
|
+
|
|
18
|
+
guard :bundler do
|
|
19
|
+
require 'guard/bundler'
|
|
20
|
+
require 'guard/bundler/verify'
|
|
21
|
+
helper = Guard::Bundler::Verify.new
|
|
22
|
+
|
|
23
|
+
files = ['Gemfile']
|
|
24
|
+
files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
|
|
25
|
+
|
|
26
|
+
# Assume files are symlinked from somewhere
|
|
27
|
+
files.each { |file| watch(helper.real_path(file)) }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
|
31
|
+
# rspec may be run, below are examples of the most common uses.
|
|
32
|
+
# * bundler: 'bundle exec rspec'
|
|
33
|
+
# * bundler binstubs: 'bin/rspec'
|
|
34
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
|
35
|
+
# installed the spring binstubs per the docs)
|
|
36
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
|
37
|
+
# * 'just' rspec: 'rspec'
|
|
38
|
+
|
|
39
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
|
40
|
+
require "guard/rspec/dsl"
|
|
41
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
|
42
|
+
|
|
43
|
+
# Feel free to open issues for suggestions and improvements
|
|
44
|
+
|
|
45
|
+
# RSpec files
|
|
46
|
+
rspec = dsl.rspec
|
|
47
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
|
48
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
|
49
|
+
watch(rspec.spec_files)
|
|
50
|
+
|
|
51
|
+
# Ruby files
|
|
52
|
+
ruby = dsl.ruby
|
|
53
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
|
54
|
+
|
|
55
|
+
# Rails files
|
|
56
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
|
57
|
+
dsl.watch_spec_files_for(rails.app_files)
|
|
58
|
+
dsl.watch_spec_files_for(rails.views)
|
|
59
|
+
|
|
60
|
+
watch(rails.controllers) do |m|
|
|
61
|
+
[
|
|
62
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
|
63
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
|
64
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
|
65
|
+
]
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Rails config changes
|
|
69
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
|
70
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
|
71
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
|
72
|
+
|
|
73
|
+
# Capybara features specs
|
|
74
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
|
75
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
|
76
|
+
|
|
77
|
+
# Turnip features and steps
|
|
78
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
|
79
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
|
80
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
|
81
|
+
end
|
|
82
|
+
end
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 David Dorta Acosta
|
|
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,41 @@
|
|
|
1
|
+
# Menus
|
|
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/menus`. 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 'menus'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install menus
|
|
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]/menus. 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
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "menus"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
class C_LinkedList
|
|
2
|
+
include Enumerable
|
|
3
|
+
attr_accessor :a_inicio, :a_fin
|
|
4
|
+
|
|
5
|
+
def initialize()
|
|
6
|
+
@a_inicio = nil
|
|
7
|
+
@a_fin = nil
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# --- Definición del Método Mixins Enumerable ---
|
|
11
|
+
|
|
12
|
+
def each
|
|
13
|
+
nodo = @a_inicio
|
|
14
|
+
while nodo != nil
|
|
15
|
+
yield nodo.value
|
|
16
|
+
nodo = nodo.next
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# --- Método que comprueba si la lista esta vacia ---
|
|
21
|
+
|
|
22
|
+
def empty
|
|
23
|
+
if ((@a_inicio == nil) && (a_fin == nil))
|
|
24
|
+
true
|
|
25
|
+
else
|
|
26
|
+
false
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# --- Método para insertar el primer elemento de la lista ---
|
|
31
|
+
|
|
32
|
+
def insert_first(value)
|
|
33
|
+
@a_fin = value
|
|
34
|
+
@a_inicio = value
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# --- Método para extraer elementos desde el inicio de la lista ---
|
|
38
|
+
|
|
39
|
+
def extract_front
|
|
40
|
+
if (empty == true)
|
|
41
|
+
puts "La lista en el metodo extract_front esta vacia"
|
|
42
|
+
else
|
|
43
|
+
aux = @a_inicio
|
|
44
|
+
@a_inicio = @a_inicio.next
|
|
45
|
+
aux
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# --- Método para insertar un elemento a la lista por el inicio ---
|
|
50
|
+
|
|
51
|
+
def push_front(nodo)
|
|
52
|
+
nodo.each do |value|
|
|
53
|
+
if (empty == true)
|
|
54
|
+
insert_first(value)
|
|
55
|
+
else
|
|
56
|
+
aux = @a_inicio
|
|
57
|
+
@a_inicio = value
|
|
58
|
+
aux.previus = @a_inicio
|
|
59
|
+
@a_inicio.next = aux
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
#--- Método para mostrar la lista Principio a Fin ---
|
|
65
|
+
|
|
66
|
+
def mostrar_inicio_fin
|
|
67
|
+
if (empty == true)
|
|
68
|
+
puts "--- La lista esta vacia ---"
|
|
69
|
+
else
|
|
70
|
+
puts
|
|
71
|
+
puts "--- LA LISTA DEL PRINCIPIO AL FINAL ES, "
|
|
72
|
+
puts
|
|
73
|
+
aux = @a_inicio
|
|
74
|
+
puts @a_inicio.value
|
|
75
|
+
while aux.next do
|
|
76
|
+
puts "--------------"
|
|
77
|
+
aux = aux.next
|
|
78
|
+
puts aux.value
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# --- Método para extraer elementos desde el final de la lista ---
|
|
84
|
+
|
|
85
|
+
def extract_back
|
|
86
|
+
if (empty == true)
|
|
87
|
+
puts "La lista en el metodo extract_back esta vacia"
|
|
88
|
+
else
|
|
89
|
+
aux = @a_fin
|
|
90
|
+
@a_fin = @a_fin.previus
|
|
91
|
+
aux
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# --- Metodo para insertar un elemento a la lista por el final ---
|
|
96
|
+
|
|
97
|
+
def push_back(nodo)
|
|
98
|
+
nodo.each do |value|
|
|
99
|
+
if (empty == true)
|
|
100
|
+
puts "---- Metodo INSERTAR_FINAL, La lista esta vacia ----"
|
|
101
|
+
insert_first(value)
|
|
102
|
+
else
|
|
103
|
+
aux = @a_fin
|
|
104
|
+
@a_fin = value
|
|
105
|
+
aux.next = @a_fin
|
|
106
|
+
@a_fin.previus = aux
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
#--- Metodo para mostrar la lista Fin a Principio ---
|
|
112
|
+
|
|
113
|
+
def mostrar_fin_inicio
|
|
114
|
+
if (empty == true)
|
|
115
|
+
puts "--- La lista esta vacia ---"
|
|
116
|
+
else
|
|
117
|
+
puts
|
|
118
|
+
puts "--- LA LISTA DEL FINAL AL PRINCIPIO ES, "
|
|
119
|
+
puts
|
|
120
|
+
|
|
121
|
+
aux = @a_fin
|
|
122
|
+
puts @a_fin.value
|
|
123
|
+
|
|
124
|
+
while aux.previus do
|
|
125
|
+
puts "--------------"
|
|
126
|
+
aux = aux.previus
|
|
127
|
+
puts aux.value
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
data/lib/menus/menu.rb
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
class Menu
|
|
2
|
+
include Comparable
|
|
3
|
+
attr_accessor :titulo, :titulo_porcentaje, :platos, :porcion, :gramos, :vct, :proteinas_porcetanje, :grasas_porcetanje, :hidratos_porcentaje
|
|
4
|
+
|
|
5
|
+
def initialize(titulo, titulo_porcentaje, platos, porcion, gramos, vct, proteinas_porcetanje, grasas_porcetanje, hidratos_porcentaje)
|
|
6
|
+
@titulo = titulo
|
|
7
|
+
@titulo_porcentaje = titulo_porcentaje
|
|
8
|
+
@platos = platos
|
|
9
|
+
@porcion = porcion
|
|
10
|
+
@gramos = gramos
|
|
11
|
+
@vct = vct
|
|
12
|
+
@proteinas_porcetanje = proteinas_porcetanje
|
|
13
|
+
@grasas_porcetanje = grasas_porcetanje
|
|
14
|
+
@hidratos_porcentaje = hidratos_porcentaje
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# --- Definición del Método Mixins para las comparaciones del módulo Comparable
|
|
18
|
+
|
|
19
|
+
def <=>(value)
|
|
20
|
+
return nil unless value.instance_of? Menu
|
|
21
|
+
@proteinas_porcetanje <=> value.proteinas_porcetanje
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def get_descripcion
|
|
25
|
+
@descripcion
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def get_titulo
|
|
29
|
+
@titulo
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def get_titulo_porcentaje
|
|
33
|
+
@titulo_porcentaje
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def get_plato(i)
|
|
37
|
+
@platos[i]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def get_platos()
|
|
41
|
+
@platos
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def get_vct()
|
|
45
|
+
@vct
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def get_proteinas_porcetanje()
|
|
49
|
+
@proteinas_porcetanje
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def get_grasas_porcentaje()
|
|
53
|
+
@grasas_porcetanje
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def get_hidratos_porcentaje()
|
|
57
|
+
@hidratos_porcentaje
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def to_s
|
|
61
|
+
buffer = "#{@titulo} #{@titulo_porcentaje}\n"
|
|
62
|
+
i = 0;
|
|
63
|
+
while i < @platos.size()
|
|
64
|
+
buffer << "- #{platos[i]}, #{porcion[i]}, #{gramos[i]} g\n"
|
|
65
|
+
i = i + 1
|
|
66
|
+
end
|
|
67
|
+
buffer << "V.C.T. | % #{@vct} kcal | #{@proteinas_porcetanje}% - #{@hidratos_porcentaje}% - #{@grasas_porcetanje}%\n"
|
|
68
|
+
return buffer
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
class Menu_DSL
|
|
2
|
+
attr_accessor :titulos, :ingesta_porcentajes, :platos, :descripcion, :porcion, :gramos, :vct, :proteinas, :grasas, :hidratos
|
|
3
|
+
|
|
4
|
+
def initialize(titulos, &block)
|
|
5
|
+
self.titulos = titulos
|
|
6
|
+
self.platos = []
|
|
7
|
+
|
|
8
|
+
if block_given?
|
|
9
|
+
if block.arity == 1
|
|
10
|
+
yield self
|
|
11
|
+
else
|
|
12
|
+
instance_eval(&block)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def titulo (name)
|
|
18
|
+
@titulos = name
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def ingesta(options = {})
|
|
22
|
+
min_max = []
|
|
23
|
+
min_max << "#{options[:min]}"
|
|
24
|
+
min_max << "#{options[:max]}"
|
|
25
|
+
@ingesta_porcentajes = min_max
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def plato(options = {})
|
|
29
|
+
ingredientes = []
|
|
30
|
+
ingredientes << "#{options[:descripcion]}, #{options[:porcion]}, #{options[:gramos]}"
|
|
31
|
+
@platos.push(ingredientes)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def porcentajes(options = {})
|
|
35
|
+
@vct = "#{options[:vct]}"
|
|
36
|
+
@proteinas = "#{options[:proteinas]}"
|
|
37
|
+
@grasas = "#{options[:grasas]}"
|
|
38
|
+
@hidratos = "#{options[:hidratos]}"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def to_s
|
|
42
|
+
buffer = "#{@titulos} "
|
|
43
|
+
buffer << "(#{@ingesta_porcentajes.join(' - ')}%)\n"
|
|
44
|
+
buffer << "- #{@platos.join("\n- ")}\n"
|
|
45
|
+
buffer << "V.C.T. | % #{@vct} kcal | #{@proteinas}% - #{@grasas}% - #{@hidratos}%\n"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Clase con Herencia
|
|
2
|
+
|
|
3
|
+
class Menu_Saludable < Menu
|
|
4
|
+
include Comparable
|
|
5
|
+
attr_accessor :grupo_alimentos, :grupo_edad
|
|
6
|
+
|
|
7
|
+
def initialize(titulo, titulo_porcentaje, platos, porcion, gramos, vct, proteinas_porcetanje, grasas_porcetanje, hidratos_porcentaje, grupo_alimentos, grupo_edad)
|
|
8
|
+
super(titulo, titulo_porcentaje, platos, porcion, gramos, vct, proteinas_porcetanje, grasas_porcetanje, hidratos_porcentaje)
|
|
9
|
+
@grupo_alimentos = grupo_alimentos
|
|
10
|
+
@grupo_edad = grupo_edad
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# --- Definición del Método Mixins para las comparaciones del módulo Comparable
|
|
14
|
+
|
|
15
|
+
def <=>(value)
|
|
16
|
+
return nil unless value.instance_of? Menu_Saludable
|
|
17
|
+
@grasas_porcetanje <=> value.grasas_porcetanje
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def get_grupo_alimentos()
|
|
21
|
+
@grupo_alimentos
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def get_grupo_edad()
|
|
25
|
+
@grupo_edad
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def to_s
|
|
29
|
+
"Menú para,\nGrupo de edad: #{@grupo_edad}\nGrupo de alimentos: #{@grupo_alimentos}\n" + super.to_s
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
data/lib/menus/node.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Node = Struct.new(:value, :next, :previus)
|
data/lib/menus.rb
ADDED
data/menus.gemspec
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'menus/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "menus_alu100851236"
|
|
8
|
+
spec.version = Menus::VERSION
|
|
9
|
+
spec.authors = ["David Dorta Acosta"]
|
|
10
|
+
spec.email = ["alu0100851236@ull.edu.es"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Practica 07 Programación Orientada a Objetos.}
|
|
13
|
+
spec.description = %q{A partir de la práctica anterior, implementar una clase para gestionar listas enlazadas.}
|
|
14
|
+
spec.homepage = "https://github.com/ULL-ESIT-LPP-1617/menu-dietetico-alu0100851236.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
|
+
=begin
|
|
20
|
+
if spec.respond_to?(:metadata)
|
|
21
|
+
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
|
22
|
+
else
|
|
23
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
24
|
+
"public gem pushes."
|
|
25
|
+
end
|
|
26
|
+
=end
|
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
28
|
+
f.match(%r{^(test|spec|features)/})
|
|
29
|
+
end
|
|
30
|
+
spec.bindir = "exe"
|
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
32
|
+
spec.require_paths = ["lib"]
|
|
33
|
+
|
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
36
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
37
|
+
spec.add_development_dependency "guard"
|
|
38
|
+
spec.add_development_dependency "guard-rspec"
|
|
39
|
+
spec.add_development_dependency "guard-bundler"
|
|
40
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: menus_alu100851236
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- David Dorta Acosta
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-12-16 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.13'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.13'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: guard
|
|
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: A partir de la práctica anterior, implementar una clase para gestionar
|
|
98
|
+
listas enlazadas.
|
|
99
|
+
email:
|
|
100
|
+
- alu0100851236@ull.edu.es
|
|
101
|
+
executables: []
|
|
102
|
+
extensions: []
|
|
103
|
+
extra_rdoc_files: []
|
|
104
|
+
files:
|
|
105
|
+
- ".gitignore"
|
|
106
|
+
- ".rspec"
|
|
107
|
+
- ".travis.yml"
|
|
108
|
+
- CODE_OF_CONDUCT.md
|
|
109
|
+
- Gemfile
|
|
110
|
+
- Guardfile
|
|
111
|
+
- LICENSE.txt
|
|
112
|
+
- README.md
|
|
113
|
+
- Rakefile
|
|
114
|
+
- bin/console
|
|
115
|
+
- bin/setup
|
|
116
|
+
- lib/menus.rb
|
|
117
|
+
- lib/menus/LinkedList.rb
|
|
118
|
+
- lib/menus/menu.rb
|
|
119
|
+
- lib/menus/menu_dsl.rb
|
|
120
|
+
- lib/menus/menu_saludable.rb
|
|
121
|
+
- lib/menus/node.rb
|
|
122
|
+
- lib/menus/version.rb
|
|
123
|
+
- menus.gemspec
|
|
124
|
+
homepage: https://github.com/ULL-ESIT-LPP-1617/menu-dietetico-alu0100851236.git
|
|
125
|
+
licenses:
|
|
126
|
+
- MIT
|
|
127
|
+
metadata: {}
|
|
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.5.1
|
|
145
|
+
signing_key:
|
|
146
|
+
specification_version: 4
|
|
147
|
+
summary: Practica 07 Programación Orientada a Objetos.
|
|
148
|
+
test_files: []
|