alu0100763768_menu 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
+ SHA1:
3
+ metadata.gz: f261faf8554e9f6f553aa223fd1431f8c4438d24
4
+ data.tar.gz: 57196f1f376d23e02d2ce0441d232425a4d4a751
5
+ SHA512:
6
+ metadata.gz: fb60fa75d9a7e1b632b1df66a1258fe2dea5f029a649a7a466e71e8221dd32a124e580dc36ed798b9f4f0413245b0de059f0997d7e7f53c7c97f691b4cd37cae
7
+ data.tar.gz: 3f382e06161d837c13c544706da42825a105b7c5d581b3e8380b2a65556dc54fafa5766be152c34c0b18f3a238ed04e3b06d0a0227765b6da0b5d4ec6bc0be33
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.*~
11
+ *.swp
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.13.6
@@ -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 alu0100813272@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,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in menu.gemspec
4
+ gemspec
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 Jairo
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
+ # Menu
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/menu`. 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 'menu'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install menu
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]/menu. 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
@@ -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 "menu"
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,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/menu.rb ADDED
@@ -0,0 +1,9 @@
1
+ require "menu/version"
2
+ require "menu/menucode.rb"
3
+ require "menu/plato.rb"
4
+ require "menu/lista.rb"
5
+ #= Modulo Menu
6
+ # * Modulo donde queremos que nuestros metodos de la gema sean públicos
7
+ module Menu
8
+ # Your code goes here...
9
+ end
data/lib/menu/lista.rb ADDED
@@ -0,0 +1,183 @@
1
+
2
+ Node = Struct.new(:datos, :siguiente, :anterior)
3
+
4
+ def Node
5
+ undef datos=, []=
6
+ end
7
+
8
+ # = Clase Lista
9
+ # Representa la lista enlazada
10
+
11
+ class Lista
12
+ include Enumerable
13
+ #==Constructor
14
+ #===Pasamos los parametros para construir un objeto Lista:
15
+ def initialize ()
16
+ @cabeza = nil
17
+ end
18
+
19
+ #* Borra el objeto de la cabeza de la Lista.
20
+ def extraerCabeza
21
+ auxiliar = @cabeza
22
+ @cabeza = auxiliar.siguiente
23
+ auxiliar.siguiente = nil
24
+ auxiliar.datos
25
+ end
26
+
27
+ #* Inserta el objeto o grupo de objetos en la cabeza de la Lista
28
+ def insertar (datos)
29
+ insertado = false
30
+ if datos.instance_of?Array
31
+ datos.each{|x| add(x)}
32
+ insertado = true
33
+ else
34
+ add(datos)
35
+ insertado = true
36
+ end
37
+ insertado
38
+ end
39
+
40
+ #* Devuelve el objeto Menú que se encuentra en la cabeza de la lista.
41
+ def cabeza
42
+ @cabeza.datos
43
+ end
44
+
45
+ private
46
+
47
+ def add (datos)
48
+ if @cabeza == nil then
49
+ @cabeza = Node.new(datos,nil)
50
+ else
51
+ nodo_aux = @cabeza
52
+ while nodo_aux.siguiente != nil
53
+ nodo_aux = nodo_aux.siguiente
54
+ end
55
+ nodo_aux.siguiente = Node.new(datos, nil)
56
+ end
57
+ end
58
+
59
+ end
60
+ # = Clase ListaEnlazada
61
+ # Representa la lista doblemente enlazada
62
+ class ListaEnlazada
63
+ include Enumerable
64
+ def initialize ()
65
+ @cabeza = nil
66
+ @cola = nil
67
+ end
68
+
69
+ def each
70
+ x = @cabeza
71
+ while x != @cola
72
+ yield x.datos
73
+ x = x.siguiente
74
+ end
75
+ yield @cola.datos
76
+ end
77
+
78
+ #* Borra el objeto de la cabeza de la Lista.
79
+ def extraerCabeza
80
+ if @cabeza != nil then
81
+ auxiliar = @cabeza
82
+ if @cabeza.siguiente != nil then
83
+ @cabeza = auxiliar.siguiente
84
+ @cabeza.anterior = nil
85
+ auxiliar.siguiente = nil
86
+ else
87
+ @cabeza = nil
88
+ @cola = nil
89
+ end
90
+ auxiliar.datos
91
+ else
92
+ @cabeza
93
+ end
94
+ end
95
+
96
+ #* Borra el objeto que está en la cola de la Lista.
97
+ def extraerCola
98
+ if @cola != nil then
99
+ auxiliar = @cola
100
+ if @cola.anterior != nil then
101
+ @cola = auxiliar.anterior
102
+ @cola.siguiente = nil
103
+ auxiliar.anterior = nil
104
+ else
105
+ @cola = nil
106
+ @cabeza = nil
107
+ end
108
+ auxiliar.datos
109
+ else
110
+ @cola
111
+ end
112
+
113
+ end
114
+
115
+ #* Inserta el objeto o grupo de objetos en la cabeza de la Lista
116
+ def insertarCabeza (datos)
117
+ insertado = false
118
+ if datos.instance_of?Array
119
+ datos.each{|x| addCabeza(x)}
120
+ insertado = true
121
+ else
122
+ addCabeza(datos)
123
+ insertado = true
124
+ end
125
+ insertado
126
+ end
127
+
128
+ #* Inserta el objeto o grupo de objetos en la cola de la Lista
129
+ def insertarCola (datos)
130
+ insertado = false
131
+ if datos.instance_of?Array
132
+ datos.each{|x| addCola(x)}
133
+ insertado = true
134
+ else
135
+ addCola(datos)
136
+ insertado = true
137
+ end
138
+ insertado
139
+ end
140
+
141
+ #* Devuelve el objeto Menú que se encuentra en la cabeza de la lista.
142
+ def cabeza
143
+ if @cabeza != nil then
144
+ @cabeza.datos
145
+ else
146
+ @cabeza
147
+ end
148
+ end
149
+
150
+ #* Devuelve el objeto Menú que se encuentra en la cola de la lista.
151
+ def cola
152
+ if @cola != nil then
153
+ @cola.datos
154
+ else
155
+ @cola
156
+ end
157
+ end
158
+
159
+ private
160
+
161
+ def addCabeza (datos)
162
+ if @cabeza == nil then
163
+ @cabeza = Node.new(datos,nil, nil)
164
+ @cola = @cabeza
165
+ else
166
+ nodo_aux = @cabeza
167
+ @cabeza = Node.new(datos, nodo_aux, nil)
168
+ nodo_aux.anterior = @cabeza
169
+ end
170
+ end
171
+
172
+ def addCola (datos)
173
+ if @cabeza == nil then
174
+ @cabeza = Node.new(datos,nil, nil)
175
+ @cola = @cabeza
176
+ else
177
+ nodo_aux = @cola
178
+ @cola = Node.new(datos, nil, nodo_aux)
179
+ nodo_aux.siguiente = @cola
180
+ end
181
+ end
182
+
183
+ end
@@ -0,0 +1,276 @@
1
+ module Menu
2
+ # = Clase Menu
3
+ # Sirve para instanciar Objetos tipo Menu.
4
+ class Menu
5
+ include Comparable
6
+
7
+ attr_reader :titulo , :porcentaje, :platos, :vct, :proteinas, :grasas, :hidratos
8
+
9
+ #==Constructor
10
+ #===Pasamos los parametros para construir un objeto menú:
11
+ # - Título: Título del menú.
12
+ # - Porcentaje: Porcentaje en Kcal.
13
+ # - Platos: Array de platos que contiene el menú.
14
+ # - Vct: Valor Calórico total.
15
+ # - Porcentaje de proteinas de la dieta.
16
+ # - Porcentaje de grasas.
17
+ # - Porcentaje de hidratos.
18
+
19
+ def initialize (titulo, porcentaje, platos, vct, proteinas, grasas, hidratos)
20
+ @titulo = titulo # - Título: Título del menú.
21
+ @porcentaje = porcentaje # - Porcentaje: Porcentaje en Kcal.
22
+ @platos = Array.new # - Platos: Array de platos que contiene el menú.
23
+ platos.each{|x| @platos.push(Plato.new(x))}
24
+ @vct = vct # - Vct: Valor Calórico total.
25
+ @proteinas = proteinas # - Porcentaje de proteinas de la dieta.
26
+ @grasas = grasas # - Porcentaje de grasas.
27
+ @hidratos = hidratos # - Porcentaje de hidratos.
28
+ end
29
+
30
+ def <=>(anOther)
31
+ return nil if anOther == nil
32
+ @vct <=> anOther.getVct
33
+ #x = [@vct, @proteinas, @grasas, @hidratos]
34
+ #y = [anOther.getVct, anOther.getProteinas, anOther.getGrasas, anOther.getHidratos]
35
+ #x <=> y
36
+ end
37
+
38
+ def ==(anOther)
39
+ return nil if anOther == nil
40
+ x = [@vct, @proteinas, @grasas, @hidratos]
41
+ y = [anOther.getVct, anOther.getProteinas, anOther.getGrasas, anOther.getHidratos]
42
+ x == y
43
+ end
44
+
45
+ #* Devuelve un string con el Menú completo correctamente formateado
46
+ def to_s
47
+
48
+ porcentaje = corregir_porcentaje
49
+
50
+ @titulo + " (#{porcentaje}%)\n" + getConjuntoPlatos + "V.C.T. | % #{getVct} kcal | #{getProteinas}% - #{getGrasas}% - #{getHidratos}%\n"
51
+ end
52
+
53
+ private
54
+ def corregir_porcentaje
55
+ t = ""
56
+ @porcentaje.each{|x| t = t + " - " + x.to_s}
57
+ final = t[3,t.length]
58
+ final
59
+ end
60
+ public
61
+ #* Devuelve el plato del índice indicado en el parámetro.
62
+ def getPlato(index)
63
+ @platos[index].to_s
64
+ end
65
+
66
+ #* Devuelve el título del Menú.
67
+ def getTitulo
68
+ @titulo
69
+ end
70
+
71
+ #* Devuelve el porcentaje de ls Ingesta Diaria recomendada.
72
+ def getIngesta
73
+ @porcentaje
74
+ end
75
+ #* Devuelve el Valor calórico total del Menú.
76
+ def getVct
77
+ @vct
78
+ end
79
+
80
+ #* Devuelve el porcentaje de proteínas del Menú.
81
+ def getProteinas
82
+ @proteinas
83
+ end
84
+
85
+ #* Devuelve el porcentaje de grasas del Menú.
86
+ def getGrasas
87
+ @grasas
88
+ end
89
+
90
+ #* Devuelve el porcentaje de hidratos de carbono del Menú.
91
+ def getHidratos
92
+ @hidratos
93
+ end
94
+ #* Devuelve la descripción de un plato del Menú.
95
+ def getDescripcion (x)
96
+ @platos[x].descripcion
97
+ end
98
+ #* Devuelve un string en formato lista con los platos del Menú.
99
+ def getConjuntoPlatos
100
+ t = ""
101
+ @platos.each{|x| t = t + x.to_s + "\n"}
102
+ t
103
+ end
104
+ end
105
+ end
106
+
107
+ # = Clase Alimentos
108
+ # La clase alimentos hereda de la clase Menu para poder organizar los Menus por grupos de alimentos.
109
+ class Alimentos < Menu::Menu
110
+
111
+ attr_reader :grupo
112
+ #==Constructor
113
+ #Pasamos los parametros para construir un objeto menú y el parámetro grupo para poder clasificarlo e instanciar un objeto de la clase Alimentos.
114
+ def initialize (titulo, porcentaje, platos, vct, proteinas, grasas, hidratos, grupo)
115
+ super(titulo, porcentaje, platos, vct, proteinas, grasas, hidratos)
116
+ @grupo = grupo
117
+ end
118
+
119
+ def to_s
120
+ s = ""
121
+ s << super.to_s
122
+ s << "Grupo: #{@grupo}\n"
123
+ s
124
+ end
125
+
126
+
127
+ end
128
+
129
+ # = Clase Edades
130
+ # La clase edades hereda de la clase Menu para poder organizar los Menus por grupos de edades.
131
+
132
+ class Edades < Menu::Menu
133
+
134
+ attr_reader :grupo
135
+
136
+ #==Constructor
137
+ #Pasamos los parametros para construir un objeto menú y el parámetro grupo para poder clasificarlo e instanciar un objeto de la clase Edades.
138
+ def initialize (titulo, porcentaje, platos, vct, proteinas, grasas, hidratos, grupo)
139
+ super(titulo, porcentaje, platos, vct, proteinas, grasas, hidratos)
140
+ @grupo = grupo
141
+ end
142
+
143
+ def to_s
144
+ s = ""
145
+ s << super.to_s
146
+ s << "Grupo: #{@grupo}\n"
147
+ s
148
+ end
149
+
150
+ end
151
+
152
+ class MenuDSL
153
+
154
+ def initialize(&bloque)
155
+ @titulo
156
+ @porcentaje
157
+ @platos = []
158
+ @vct
159
+ @proteinas
160
+ @grasas
161
+ @hidratos
162
+ @grupo
163
+ @edades
164
+
165
+ if block_given?
166
+ if bloque.arity == 1
167
+ yield self
168
+ else
169
+ instance_eval(&bloque)
170
+ end
171
+ end
172
+ end
173
+
174
+ def titulo (name, options = {})
175
+ @titulo = name
176
+ @grupo = "#{options[:grupo]}" if options[:grupo]
177
+ @edades = "#{options[:edad]}" if options[:edad]
178
+ end
179
+
180
+ def ingesta (options = {})
181
+ porcentaje = []
182
+ porcentaje << "#{options[:min]}" if options[:min]
183
+ porcentaje << "#{options[:max]}" if options[:max]
184
+ @porcentaje = porcentaje
185
+ end
186
+
187
+ def plato (options = {})
188
+ plato = []
189
+ plato << "#{options[:descripcion]}" if options[:descripcion]
190
+ plato << "#{options[:porcion]}" if options[:porcion]
191
+ plato << "#{options[:gramos]}" if options[:gramos]
192
+ @platos.push(Plato.new(plato))
193
+ end
194
+
195
+ def porcentajes (options = {})
196
+ @vct = "#{options[:vct]}" if options[:vct]
197
+ @proteinas = "#{options[:proteinas]}" if options[:proteinas]
198
+ @grasas = "#{options[:grasas]}" if options[:grasas]
199
+ @hidratos = "#{options[:hidratos]}" if options[:hidratos]
200
+ end
201
+
202
+
203
+
204
+ def to_s
205
+
206
+ porcentaje = corregir_porcentaje
207
+
208
+ @titulo + " (#{porcentaje}%)\n" + getConjuntoPlatos + "V.C.T. | % #{getVct} kcal | #{getProteinas}% - #{getGrasas}% - #{getHidratos}%\n Grupo de alimentos: #{getGrupo}\n Grupo de edad: #{getEdades}\n"
209
+ end
210
+
211
+ # METODOS GET ###################################################################################################################################
212
+ #* Devuelve el plato del índice indicado en el parámetro.
213
+ def getPlato(index)
214
+ @platos[index].to_s
215
+ end
216
+
217
+ #* Devuelve el título del Menú.
218
+ def getTitulo
219
+ @titulo
220
+ end
221
+
222
+ #* Devuelve el porcentaje de ls Ingesta Diaria recomendada.
223
+ def getIngesta
224
+ @porcentaje
225
+ end
226
+ #* Devuelve el Valor calórico total del Menú.
227
+ def getVct
228
+ @vct
229
+ end
230
+
231
+ #* Devuelve el porcentaje de proteínas del Menú.
232
+ def getProteinas
233
+ @proteinas
234
+ end
235
+
236
+ #* Devuelve el porcentaje de grasas del Menú.
237
+ def getGrasas
238
+ @grasas
239
+ end
240
+
241
+ #* Devuelve el porcentaje de hidratos de carbono del Menú.
242
+ def getHidratos
243
+ @hidratos
244
+ end
245
+
246
+ #* Devuelve la descripción de un plato del Menú.
247
+ def getDescripcion (x)
248
+ @platos[x].descripcion
249
+ end
250
+
251
+ #* Devuelve un string en formato lista con los platos del Menú.
252
+ def getConjuntoPlatos
253
+ t = ""
254
+ @platos.each{|x| t = t + x.to_s + "\n"}
255
+ t
256
+ end
257
+
258
+ #* Devuelve el Grupo de alimentos al que pertenece el Menú.
259
+ def getGrupo
260
+ @grupo
261
+ end
262
+
263
+ #* Devuelve el Grupo de edad al que pertenece el Menú.
264
+ def getEdades
265
+ @edades
266
+ end
267
+ #################################################################################################################################################
268
+
269
+ private
270
+ def corregir_porcentaje
271
+ t = ""
272
+ @porcentaje.each{|x| t = t + " - " + x.to_s}
273
+ final = t[3,t.length]
274
+ final
275
+ end
276
+ end
data/lib/menu/plato.rb ADDED
@@ -0,0 +1,19 @@
1
+ # = Clase Plato
2
+ # Sirve para instanciar Objetos tipo Plato.
3
+ class Plato
4
+ attr_reader :descripcion, :porcion, :ingesta
5
+ #==Constructor
6
+ #===Pasamos los parametros para construir un objeto Plato:
7
+ # - plato: Parámetro de tipo array de strings en donde se describe el plato, la porción y la ingesta.
8
+
9
+ def initialize(plato)
10
+ @descripcion = "- #{plato[0]}"
11
+ @porcion = plato[1]
12
+ @ingesta = plato[2]
13
+ end
14
+
15
+ def to_s
16
+ "#{@descripcion}, #{@porcion}, #{@ingesta}"
17
+ end
18
+
19
+ end
@@ -0,0 +1,3 @@
1
+ module Menu
2
+ VERSION = "0.1.0"
3
+ end
data/menu.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'menu/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "alu0100763768_menu"
8
+ spec.version = Menu::VERSION
9
+ spec.authors = ["Andrés Eloy Castro Mancini"]
10
+ spec.email = ["alu0100763768@ull.edu.es"]
11
+
12
+ spec.summary = %q{Práctica 11 de la asignatura de Lenguajes y Paradigmas de Programación.}
13
+ spec.description = %q{Diseñar e implementar un Lenguaje de Dominio Específico DSL, que permita la definición de listas de menús dietéticos diarios y semanales.}
14
+ spec.homepage = "https://github.com/ULL-ESIT-LPP-1617/menu-dietetico-alu0100763768.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
+
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
+ f.match(%r{^(test|spec|features)/})
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.13"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.0"
31
+ spec.add_development_dependency "guard"
32
+ spec.add_development_dependency "guard-rspec"
33
+ spec.add_development_dependency "guard-bundler"
34
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alu0100763768_menu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrés Eloy Castro Mancini
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-12-12 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: Diseñar e implementar un Lenguaje de Dominio Específico DSL, que permita
98
+ la definición de listas de menús dietéticos diarios y semanales.
99
+ email:
100
+ - alu0100763768@ull.edu.es
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".travis.yml"
107
+ - CODE_OF_CONDUCT.md
108
+ - Gemfile
109
+ - Guardfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/setup
115
+ - lib/menu.rb
116
+ - lib/menu/lista.rb
117
+ - lib/menu/menucode.rb
118
+ - lib/menu/plato.rb
119
+ - lib/menu/version.rb
120
+ - menu.gemspec
121
+ homepage: https://github.com/ULL-ESIT-LPP-1617/menu-dietetico-alu0100763768.git
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.4.8
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Práctica 11 de la asignatura de Lenguajes y Paradigmas de Programación.
145
+ test_files: []