menualu0100813272 0.1.5

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
+ SHA1:
3
+ metadata.gz: 5f8e16722881d6045346aa75eae389274565de8f
4
+ data.tar.gz: b09be32bd92e83bbaf25782e24deea735da2eab0
5
+ SHA512:
6
+ metadata.gz: e0d4421c8a22850af5374724c609b2382bec33642e8067f2df08f799c58a4bb8696d4b3462f3c930ce6bea8c156f6145c3228cfcab6b4d9dc8de4733a6f55f10
7
+ data.tar.gz: f234d5b446412298e69ef74540e9bf9fcc1e0890377cac607bd19a3de11081ac3fc20853db186990dbc4981cc7523bc00464204fcfe7ead4629dd26018a0b899
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
@@ -0,0 +1,34 @@
1
+ require "menu"
2
+ module Menu
3
+
4
+
5
+ class MGEdad < Menu
6
+ attr_reader :grupo
7
+
8
+ def initialize(grupo,titulo, porcentaje, platos, vct, proteinas, grasas, hidratos)
9
+ @grupo=grupo
10
+ super(titulo, porcentaje, platos, vct, proteinas, grasas, hidratos)
11
+ end
12
+
13
+ def to_s
14
+ lee= @grupo.center(100,"-")
15
+ lee = lee+" \n" + super.to_s
16
+ end
17
+
18
+ end
19
+
20
+ class MGAlimento < Menu
21
+ attr_reader :grupo
22
+
23
+ def initialize(grupo,titulo, porcentaje, platos, vct, proteinas, grasas, hidratos)
24
+ @grupo=grupo
25
+ super(titulo, porcentaje, platos, vct, proteinas, grasas, hidratos)
26
+ end
27
+
28
+ def to_s
29
+ lee= @grupo.center(100,"-")
30
+ lee = lee+" \n" + super.to_s
31
+ end
32
+ end
33
+
34
+ end
data/lib/menu/lista.rb ADDED
@@ -0,0 +1,84 @@
1
+ Node = Struct.new(:value, :next)
2
+
3
+ class Lista
4
+
5
+ attr_reader :inicio,:cont
6
+
7
+
8
+
9
+ def initialize()
10
+ @inicio = nil
11
+ @cont = 0
12
+ end
13
+
14
+ def insertar (nodos)
15
+ insert = false
16
+
17
+ if nodos.instance_of?Array
18
+ nodos.each do |x|
19
+ introduce(x)
20
+ end
21
+ insert = true
22
+ else
23
+ introduce(nodos)
24
+ insert = true
25
+ end
26
+
27
+ return insert
28
+ end
29
+
30
+ def introduce(nodo)
31
+ insert = false
32
+
33
+ if @inicio ==nil
34
+
35
+ @inicio=nodo
36
+ insert = true
37
+
38
+ else
39
+ aux=@inicio
40
+
41
+ while aux.next!=nil
42
+ aux = aux.next
43
+ end
44
+ aux.next =nodo
45
+ insert = true
46
+ end
47
+
48
+ @cont= @cont+1
49
+ return insert
50
+ end
51
+
52
+ def imprime
53
+ aux=@inicio
54
+ ##tenia aux pero lo pusco como axu.next
55
+ while aux!=nil
56
+ lee=aux.value.to_s
57
+ puts lee+ "\n"
58
+ aux= aux.next
59
+ end
60
+ end
61
+
62
+
63
+
64
+ def extraeInicio
65
+ extrae=false
66
+ if @inicio==nil
67
+
68
+ @inicio=nil
69
+
70
+ else
71
+ aux = @inicio
72
+ @inicio = aux.next
73
+ aux.next = nil
74
+ extrae=true
75
+ @cont= @cont-1
76
+ end
77
+ aux.value
78
+ end
79
+
80
+
81
+ end
82
+
83
+
84
+
@@ -0,0 +1,196 @@
1
+ NodeDoble = Struct.new(:value, :next,:prev)
2
+
3
+ #Clase ListaDoble lista de nodo doble se recorre en cualquier sentido
4
+ class ListaDoble
5
+ include Enumerable
6
+ attr_reader :inicio,:cont,:final
7
+ def initialize()
8
+ @inicio = nil
9
+ @final = nil
10
+ @cont = 0
11
+ end
12
+
13
+ def each
14
+ aux=@inicio
15
+
16
+ while aux!= nil
17
+ yield aux.value
18
+ aux= aux.next
19
+ end
20
+
21
+ end
22
+
23
+ #Insertar el nodo por el comienzo y comprueba si la insertar a tenido exido
24
+ def insertarFinal (nodos)
25
+ insert = false
26
+
27
+ if nodos.instance_of?Array
28
+ nodos.each do |x|
29
+ introduceFinal(x)
30
+ end
31
+ insert = true
32
+ else
33
+ introduceFinal(nodos)
34
+ insert = true
35
+ end
36
+
37
+ return insert
38
+ end
39
+
40
+
41
+ def insertarInicio (nodos)
42
+ insert = false
43
+
44
+ if nodos.instance_of?Array
45
+ nodos.each do |x|
46
+ introduceInicio(x)
47
+ end
48
+ insert = true
49
+ else
50
+ introduceInicio(nodos)
51
+ insert = true
52
+ end
53
+
54
+ return insert
55
+ end
56
+
57
+
58
+ #Comprobacion si la lista esta vacia
59
+ def is_empty?
60
+ aux=false
61
+ if @inicio==nil and @final==nil
62
+ aux=true
63
+ end
64
+ aux
65
+ end
66
+
67
+ #Imprimir los objetos de la lista
68
+ def to_s
69
+ aux=@inicio
70
+ lee=""
71
+
72
+ while aux!= nil
73
+
74
+ lee =lee+ aux.value.to_s + "\n"
75
+
76
+ aux= aux.next
77
+ end
78
+
79
+ return lee
80
+ end
81
+
82
+ #Introduce siempre por el nodo final
83
+ def introduceFinal(nodo)
84
+ insert = false
85
+
86
+ if is_empty?
87
+
88
+ @inicio=nodo
89
+ #Para que sean nodo distinto sino final y iniciio seri ael mismo nodo
90
+ aux =NodeDoble.new(nodo.value,nil,nil);
91
+ @final = aux
92
+ insert = true
93
+
94
+ else
95
+ if @final.prev == nil
96
+
97
+ @final=nodo
98
+ @final.prev=@inicio
99
+ @inicio.next=@final
100
+ insert= true
101
+
102
+ else
103
+ nodo.prev=@final
104
+ @final.next=nodo
105
+ @final=nodo
106
+ insert= true
107
+
108
+ end
109
+ end
110
+ @cont= @cont+1
111
+ return insert
112
+ end
113
+
114
+ def introduceInicio(nodo)
115
+ insert = false
116
+
117
+ if is_empty?
118
+
119
+ @final=nodo
120
+ #Para que sean nodo distinto sino final y iniciio seri ael mismo nodo
121
+ aux =NodeDoble.new(nodo.value,nil,nil);
122
+ @inicio = aux
123
+ insert = true
124
+
125
+ else
126
+ if @final.prev == nil
127
+
128
+ @inicio=nodo
129
+ @final.prev=@inicio
130
+ @inicio.next=@final
131
+
132
+ insert= true
133
+ else
134
+
135
+ @inicio.prev=nodo
136
+ nodo.next=@inicio
137
+ @inicio= @inicio.prev
138
+ insert= true
139
+
140
+ end
141
+ end
142
+ @cont= @cont+1
143
+ return insert
144
+ end
145
+
146
+ #Extraer el nodo inicio y eliminarlo de mi lista
147
+ def extraeInicio
148
+ aux=NodeDoble.new(@inicio.value,nil,nil)
149
+
150
+ if @inicio==nil
151
+ aux=nil
152
+ @inicio=nil
153
+ else
154
+
155
+ if @final.prev == nil
156
+ @final=nil
157
+ @inicio=nil
158
+ else
159
+ auxdos=@inicio
160
+ @inicio = @inicio.next
161
+ auxdos.next = nil
162
+ end
163
+
164
+
165
+ @cont= @cont-1
166
+ end
167
+
168
+ aux
169
+ end
170
+
171
+ #Extraer el nodo final y eliminarlo de mi lista
172
+ def extraeFinal
173
+ aux=NodeDoble.new(@final.value,nil,nil)
174
+
175
+ if @final==nil
176
+ aux=nil
177
+ @final=nil
178
+ else
179
+
180
+ if @final.prev == nil
181
+ @final=nil
182
+ @inicio=nil
183
+ else
184
+ auxdos=@final
185
+ @final = @final.prev
186
+ auxdos.prev = nil
187
+ end
188
+
189
+ @cont= @cont-1
190
+ end
191
+
192
+ aux
193
+ end
194
+
195
+
196
+ end
@@ -0,0 +1,96 @@
1
+ #module Menu donde estara la gema menus que gestionara uan lista de menus
2
+ module Menu
3
+ class Menu
4
+
5
+ include Comparable
6
+ attr_reader :titulo , :porcentaje, :platos, :vct, :proteinas, :grasas, :hidratos
7
+ def initialize (titulo, porcentaje, platos, vct, proteinas, grasas, hidratos)
8
+ @titulo = titulo
9
+ @porcentaje = porcentaje
10
+ @platos = Array.new
11
+ platos.each{|x| @platos.push(Plato.new(x))}
12
+ @vct = vct
13
+ @proteinas = proteinas
14
+ @grasas = grasas
15
+ @hidratos = hidratos
16
+
17
+ end
18
+
19
+ #Métdodo auxiliar que le pasas un string por parametro y nos lo transformaen float.
20
+ def cogefloat(dato)
21
+ number =dato.gsub(/[a-z]/,"")
22
+ number =number.gsub("%",".")
23
+ number =number.gsub(",",".")
24
+ number =number.to_f
25
+ return number
26
+ end
27
+
28
+
29
+ def <=>(anOther)
30
+ return nil if anOther == nil
31
+ x=[ cogefloat(vct)]
32
+ y=[ cogefloat(anOther.vct)]
33
+ x <=> y
34
+ end
35
+
36
+ def ==(anOther)
37
+ return nil if anOther == nil
38
+ x=[ cogefloat(vct), cogefloat(proteinas), cogefloat(grasas), cogefloat(hidratos) ]
39
+ y=[ cogefloat(anOther.vct), cogefloat(anOther.proteinas), cogefloat(anOther.grasas), cogefloat(anOther.hidratos) ]
40
+ x==y
41
+ end
42
+
43
+
44
+ def to_s
45
+ porcentaje = corregir_porcentaje
46
+ @titulo + " (#{porcentaje}%)\n" + getConjuntoPlatos + "V.C.T. | % " + getVct + " | " + getProteinas + " - " + getGrasas + " - " + getHidrados + "\n"
47
+ end
48
+
49
+ def corregir_porcentaje
50
+ t = ""
51
+ @porcentaje.each{|x| t = t + " - " + x.to_s}
52
+ final = t[3,t.length]
53
+ final
54
+ end
55
+
56
+ def getPlato(index)
57
+ @platos[index].to_s
58
+ end
59
+
60
+ def getTitulo
61
+ @titulo
62
+ end
63
+
64
+ def getIngesta
65
+ @porcentaje
66
+ end
67
+
68
+ def getVct
69
+ @vct
70
+ end
71
+
72
+ def getProteinas
73
+ @proteinas
74
+ end
75
+
76
+ def getGrasas
77
+ @grasas
78
+ end
79
+
80
+ def getHidrados
81
+ @hidratos
82
+ end
83
+
84
+ def getDescripcion (x)
85
+ @platos[x].descripcion
86
+ end
87
+
88
+ def getConjuntoPlatos
89
+ t = ""
90
+ @platos.each{|x| t = t + x.to_s + "\n"}
91
+ t
92
+ end
93
+ end
94
+
95
+
96
+ end
@@ -0,0 +1,142 @@
1
+ require "menu"
2
+
3
+
4
+ class MenuDE
5
+ include Comparable
6
+ attr_reader :titulo , :porcentaje, :platos, :vct, :proteinas, :grasas, :hidratos, :grupo, :edades
7
+
8
+ def initialize(&bloque)
9
+ @titulo
10
+ @porcentaje
11
+ @platos = []
12
+ @vct
13
+ @proteinas
14
+ @grasas
15
+ @hidratos
16
+ @grupo
17
+ @edades
18
+
19
+ if block_given?
20
+ if bloque.arity == 1
21
+ yield self
22
+ else
23
+ instance_eval(&bloque)
24
+ end
25
+ end
26
+ end
27
+
28
+ def plato (options = {})
29
+ plato = []
30
+ plato << "#{options[:descripcion]}" if options[:descripcion]
31
+ plato << "#{options[:porcion]}" if options[:porcion]
32
+ plato << "#{options[:gramos]}" if options[:gramos]
33
+ @platos.push(Plato.new(plato))
34
+ end
35
+
36
+ def titulo (name, options = {})
37
+ @titulo = name
38
+ @grupo = "#{options[:grupo]}" if options[:grupo]
39
+ @edades = "#{options[:edad]}" if options[:edad]
40
+ end
41
+
42
+ def ingesta (options = {})
43
+ porcentaje = []
44
+ porcentaje << "#{options[:min]}" if options[:min]
45
+ porcentaje << "#{options[:max]}" if options[:max]
46
+ @porcentaje = porcentaje
47
+ end
48
+
49
+ def porcentajes (options = {})
50
+ @vct = "#{options[:vct]}" if options[:vct]
51
+ @proteinas = "#{options[:proteinas]}" if options[:proteinas]
52
+ @grasas = "#{options[:grasas]}" if options[:grasas]
53
+ @hidratos = "#{options[:hidratos]}" if options[:hidratos]
54
+ end
55
+
56
+
57
+
58
+ #Métdodo auxiliar que le pasas un string por parametro y nos lo transformaen float.
59
+ def cogefloat(dato)
60
+ number =dato.gsub(/[a-z]/,"")
61
+ number =number.gsub("%",".")
62
+ number =number.gsub(",",".")
63
+ number =number.to_f
64
+ return number
65
+ end
66
+
67
+
68
+ def <=>(anOther)
69
+ return nil if anOther == nil
70
+ x=[ cogefloat(vct)]
71
+ y=[ cogefloat(anOther.vct)]
72
+ x <=> y
73
+ end
74
+
75
+ def ==(anOther)
76
+ return nil if anOther == nil
77
+ x=[ cogefloat(vct), cogefloat(proteinas), cogefloat(grasas), cogefloat(hidratos) ]
78
+ y=[ cogefloat(anOther.vct), cogefloat(anOther.proteinas), cogefloat(anOther.grasas), cogefloat(anOther.hidratos) ]
79
+ x==y
80
+ end
81
+
82
+
83
+ def to_s
84
+ porcentaje = corregir_porcentaje
85
+ @titulo + " (#{porcentaje}%)\n" + getConjuntoPlatos + "V.C.T. | % " + getVct + " kcal | " + getProteinas + "% - " + getGrasas + "% - " +
86
+ getHidrados + "%\n Grupo de alimentos: " + grupo.to_s + "\n Grupo de edad: " + edades.to_s + "\n"
87
+ end
88
+
89
+ def corregir_porcentaje
90
+ t = ""
91
+ @porcentaje.each{|x| t = t + " - " + x.to_s}
92
+ final = t[3,t.length]
93
+ final
94
+ end
95
+
96
+ def getPlato(index)
97
+ @platos[index].to_s
98
+ end
99
+
100
+ def getTitulo
101
+ @titulo
102
+ end
103
+
104
+ def getIngesta
105
+ @porcentaje
106
+ end
107
+
108
+ def getVct
109
+ @vct
110
+ end
111
+
112
+ def getProteinas
113
+ @proteinas
114
+ end
115
+
116
+ def getGrasas
117
+ @grasas
118
+ end
119
+
120
+ def getHidrados
121
+ @hidratos
122
+ end
123
+
124
+ def getDescripcion (x)
125
+ @platos[x].descripcion
126
+ end
127
+
128
+ def getConjuntoPlatos
129
+ t = ""
130
+ @platos.each{|x| t = t + x.to_s + "\n"}
131
+ t
132
+ end
133
+ end
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
data/lib/menu/plato.rb ADDED
@@ -0,0 +1,27 @@
1
+ # = plato.rb
2
+ #
3
+ # Autor:: Jairo Gonzalez Lemus
4
+ #
5
+ #
6
+ # === Clase Persona
7
+ #
8
+ # Definición de la clase plato compuesta por
9
+ # * metodo initialize
10
+ # * metodo saludar
11
+ #
12
+ class Plato
13
+ attr_reader :descripcion, :porcion, :ingesta
14
+
15
+ def initialize(plato)
16
+ @descripcion = "- #{plato[0]}"
17
+ @porcion = plato[1]
18
+ @ingesta = plato[2]
19
+ end
20
+
21
+
22
+ def to_s
23
+ s="#{@descripcion}, #{@porcion}, #{@ingesta}"
24
+ s
25
+ end
26
+
27
+ end
@@ -0,0 +1,3 @@
1
+ module Menu
2
+ VERSION = "0.1.5"
3
+ end
data/lib/menu.rb ADDED
@@ -0,0 +1,12 @@
1
+ require "menu/version"
2
+ require "menu/menucode.rb"
3
+ require "menu/plato.rb"
4
+ require "menu/lista.rb"
5
+ require "menu/listadoble.rb"
6
+ require "menu/grupos.rb"
7
+ require "menu/menude.rb"
8
+
9
+
10
+ module Menu
11
+ # Your code goes here...
12
+ end
data/menu.gemspec ADDED
@@ -0,0 +1,44 @@
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 = "menualu0100813272"
8
+ spec.version = Menu::VERSION
9
+ spec.authors = ["Jairo González Lemus "]
10
+ spec.email = ["alu0100813272@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{Lenguajes de dominio especifico }
14
+ spec.homepage = "https://github.com/ULL-ESIT-LPP-1617/menu-dietetico-alu0100813272.git"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['alu0100813272'] = "http://rubygems.org/sign_up"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+
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
+
38
+ spec.add_development_dependency "guard"
39
+ spec.add_development_dependency "guard-rspec"
40
+ spec.add_development_dependency "guard-bundler"
41
+
42
+
43
+
44
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: menualu0100813272
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
5
+ platform: ruby
6
+ authors:
7
+ - 'Jairo González Lemus '
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: 'Lenguajes de dominio especifico '
98
+ email:
99
+ - alu0100813272@ull.edu.es
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".travis.yml"
106
+ - CODE_OF_CONDUCT.md
107
+ - Gemfile
108
+ - Guardfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - bin/console
113
+ - bin/setup
114
+ - lib/menu.rb
115
+ - lib/menu/grupos.rb
116
+ - lib/menu/lista.rb
117
+ - lib/menu/listadoble.rb
118
+ - lib/menu/menucode.rb
119
+ - lib/menu/menude.rb
120
+ - lib/menu/plato.rb
121
+ - lib/menu/version.rb
122
+ - menu.gemspec
123
+ homepage: https://github.com/ULL-ESIT-LPP-1617/menu-dietetico-alu0100813272.git
124
+ licenses:
125
+ - MIT
126
+ metadata:
127
+ alu0100813272: http://rubygems.org/sign_up
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: Práctica 11 de la asignatura de Lenguajes y Paradigmas de Programación.
148
+ test_files: []