menu_alu0100767803 0.1.1
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 +10 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/Guardfile +82 -0
- data/README.md +41 -0
- data/Rakefile +16 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/menu/lista.rb +189 -0
- data/lib/menu/menu.rb +124 -0
- data/lib/menu/menu_alimento.rb +17 -0
- data/lib/menu/menu_dsl.rb +76 -0
- data/lib/menu/menu_edad.rb +18 -0
- data/lib/menu/plato.rb +19 -0
- data/lib/menu/version.rb +3 -0
- data/lib/menu.rb +11 -0
- data/menu.gemspec +43 -0
- metadata +144 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0346f9849f8ac31eea1e0529cf38a6018be624b1
|
4
|
+
data.tar.gz: 0f5432f855d88bed6e3296da77516dba172044ba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ac3015964592878fb135cdff4d1f95e244e58fbcbad314c3e587a395a0572e8890d6f18319bf1f2c59a43c69b76809916206db947445fe03d0e19fb011e334fc
|
7
|
+
data.tar.gz: 4d8491acd4355c414c9764615d7f10b0a49ae55c3285237fa18a52374f701262925480f3d24997cc8ea1c2a08b0ea8eaf778eacc31e10ba09c804017cc5c0897
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
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/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
|
+
## Authors
|
34
|
+
|
35
|
+
* Jorge Alonso Hernández
|
36
|
+
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/menu.
|
41
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new
|
5
|
+
|
6
|
+
task :default => :spec
|
7
|
+
|
8
|
+
#desc "Ejecutar las espectativas de la clase Menu"
|
9
|
+
#task :spec do
|
10
|
+
# sh "rspec -I. spec/menu_spec.rb"
|
11
|
+
#end
|
12
|
+
|
13
|
+
#desc "Ejecutar con documentacion"
|
14
|
+
#task :doc do
|
15
|
+
# sh "rspec -I. spec/menu_spec.rb --format documentation"
|
16
|
+
#end
|
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
data/lib/menu/lista.rb
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
Nodo = Struct.new(:value, :next, :prev) #Struct que representa a un nodo de la lista
|
2
|
+
|
3
|
+
|
4
|
+
#Clase que representa una lista doblemente enlazada de nodos
|
5
|
+
class Lista
|
6
|
+
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
attr_accessor :head, :tail
|
10
|
+
|
11
|
+
#Constructor
|
12
|
+
def initialize
|
13
|
+
@head = nil
|
14
|
+
@tail = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
#Método para comprobar si la lista está vacía
|
18
|
+
def is_empty?
|
19
|
+
if @head == nil
|
20
|
+
true
|
21
|
+
else
|
22
|
+
false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
#Método que devuelve el tamaño de la lista
|
27
|
+
def size
|
28
|
+
current = @head
|
29
|
+
i = 0
|
30
|
+
if !is_empty?
|
31
|
+
while current.next != nil
|
32
|
+
i += 1
|
33
|
+
current = current.next
|
34
|
+
end
|
35
|
+
i += 1
|
36
|
+
end
|
37
|
+
|
38
|
+
i
|
39
|
+
end
|
40
|
+
|
41
|
+
#Método que devuelve el nodo del índice que se le pasa
|
42
|
+
def obtener_elem_lista(index)
|
43
|
+
i = 0;
|
44
|
+
elem = nil;
|
45
|
+
current = @head
|
46
|
+
if index < size && index >= 0
|
47
|
+
while current.next != nil
|
48
|
+
if i == index
|
49
|
+
elem = current
|
50
|
+
end
|
51
|
+
|
52
|
+
current = current.next
|
53
|
+
i += 1
|
54
|
+
end
|
55
|
+
|
56
|
+
if i == index
|
57
|
+
elem = current
|
58
|
+
end
|
59
|
+
end
|
60
|
+
elem
|
61
|
+
end
|
62
|
+
|
63
|
+
#Método each para Enumerable
|
64
|
+
def each
|
65
|
+
current = @head
|
66
|
+
while current.next != nil
|
67
|
+
yield current.value
|
68
|
+
current = current.next
|
69
|
+
end
|
70
|
+
yield current.value
|
71
|
+
end
|
72
|
+
|
73
|
+
#Método que imprime por pantalla todos los menus de la lista
|
74
|
+
def mostrar
|
75
|
+
current = @head
|
76
|
+
while current.next != nil
|
77
|
+
puts current.value.to_s
|
78
|
+
current = current.next
|
79
|
+
end
|
80
|
+
puts current.value.to_s
|
81
|
+
end
|
82
|
+
|
83
|
+
#metodos para insertar en la lista
|
84
|
+
|
85
|
+
#Método que inserta un nodo al final de la lista
|
86
|
+
def push(nodo)
|
87
|
+
if is_empty?
|
88
|
+
@head = nodo
|
89
|
+
@tail = nodo
|
90
|
+
else
|
91
|
+
@tail.next = nodo
|
92
|
+
nodo.prev = @tail
|
93
|
+
@tail = nodo
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
#Método que inserta un nodo en el índice que se le pasa
|
98
|
+
def push_index(index, nodo)
|
99
|
+
i = 0;
|
100
|
+
current = @head
|
101
|
+
anterior = @head
|
102
|
+
if index < size && index >= 0
|
103
|
+
while current.next != nil
|
104
|
+
if index == i
|
105
|
+
anterior.next = nodo
|
106
|
+
nodo.prev = anterior
|
107
|
+
nodo.next = current
|
108
|
+
current.prev = nodo
|
109
|
+
end
|
110
|
+
|
111
|
+
anterior = current
|
112
|
+
current = current.next
|
113
|
+
i += 1
|
114
|
+
end
|
115
|
+
|
116
|
+
if index == i
|
117
|
+
anterior.next = nodo
|
118
|
+
nodo.prev = anterior
|
119
|
+
nodo.next = current
|
120
|
+
current.prev = nodo
|
121
|
+
end
|
122
|
+
else
|
123
|
+
raise ArgumentError.new("El indice es erroneo")
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
#Método que inserta varios nodos al final de la lista
|
129
|
+
def push_nodos(nodos)
|
130
|
+
i = 0
|
131
|
+
while i < nodos.length
|
132
|
+
push(nodos[i])
|
133
|
+
i += 1
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
#Método que inserta un nodo al principio de la lista
|
138
|
+
def push_start(nodo)
|
139
|
+
nodo.next = @head
|
140
|
+
@head.prev = nodo
|
141
|
+
@head = nodo
|
142
|
+
end
|
143
|
+
|
144
|
+
#metodos para eliminar de la lista
|
145
|
+
|
146
|
+
#Método que elimina el nodo final de la lista
|
147
|
+
def pop
|
148
|
+
@tail = @tail.prev
|
149
|
+
@tail.next = nil
|
150
|
+
end
|
151
|
+
|
152
|
+
#Método que elimina el nodo del índice que se le pasa
|
153
|
+
def pop_index(index)
|
154
|
+
|
155
|
+
if index < size && index >= 0
|
156
|
+
current = @head
|
157
|
+
anterior = @head
|
158
|
+
i = 0;
|
159
|
+
while current.next != nil
|
160
|
+
if index == i
|
161
|
+
anterior.next = current.next
|
162
|
+
siguiente = current.next
|
163
|
+
siguiente.prev = anterior
|
164
|
+
end
|
165
|
+
|
166
|
+
anterior = current
|
167
|
+
current = current.next
|
168
|
+
i += 1
|
169
|
+
end
|
170
|
+
|
171
|
+
if index == i
|
172
|
+
anterior.next = current.next
|
173
|
+
end
|
174
|
+
|
175
|
+
else
|
176
|
+
raise ArgumentError.new("El indice es erroneo")
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
#Método que elimina el nodo del principio de la lista
|
182
|
+
def pop_start()
|
183
|
+
nodo = @head.next
|
184
|
+
nodo.prev = nil
|
185
|
+
@head.next = nil
|
186
|
+
|
187
|
+
@head = nodo
|
188
|
+
end
|
189
|
+
end
|
data/lib/menu/menu.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
#Clase para representar recetas de cocina
|
2
|
+
|
3
|
+
class MenuDieta
|
4
|
+
|
5
|
+
include Comparable
|
6
|
+
|
7
|
+
attr_accessor :titulo, :porcentaje, :calorias, :porcentajeProteinas, :porcentajeGrasas, :porcentajeHidratos, :platos
|
8
|
+
|
9
|
+
#Constructor de recetas
|
10
|
+
def initialize(titulo, porc, platos, calorias, porcentajesVCT)
|
11
|
+
@titulo = titulo
|
12
|
+
@porcentaje = "(" + porc + ")"
|
13
|
+
@calorias = calorias
|
14
|
+
|
15
|
+
@platos = []
|
16
|
+
crearPlatos(platos)
|
17
|
+
|
18
|
+
@porcentajeProteinas
|
19
|
+
@porcentajeGrasas
|
20
|
+
@porcentajeHidratos
|
21
|
+
dividePorcentajes(porcentajesVCT)
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
#Método que crea los platos de la receta de cocina
|
26
|
+
def crearPlatos(vectorPlatos)
|
27
|
+
i = 0
|
28
|
+
while i < vectorPlatos.length do
|
29
|
+
plato = vectorPlatos[i].split(", ")
|
30
|
+
nuevoPlato = Plato.new(plato[0], plato[1], plato[2])
|
31
|
+
@platos.push(nuevoPlato)
|
32
|
+
i += 1
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
#Método que divide el string de porcentajes en porcentaje de proteinas, grasas e hidratos
|
38
|
+
def dividePorcentajes(porcentajes)
|
39
|
+
vector = porcentajes.split(" - ")
|
40
|
+
|
41
|
+
setPorcentajeProteinas(vector[0])
|
42
|
+
setPorcentajeGrasas(vector[1])
|
43
|
+
setPorcentajeHidratos(vector[2])
|
44
|
+
end
|
45
|
+
|
46
|
+
#Método que obtiene el conjunto de platos de la receta
|
47
|
+
def get_conjunto_platos
|
48
|
+
i = 1
|
49
|
+
salida = @platos[0].to_s + "\n"
|
50
|
+
while (i < @platos.length) do
|
51
|
+
salida += @platos[i].to_s + "\n"
|
52
|
+
i += 1
|
53
|
+
end
|
54
|
+
salida
|
55
|
+
end
|
56
|
+
|
57
|
+
#Método que obtiene un plato según el índice que se le pasa
|
58
|
+
def get_plato(index)
|
59
|
+
if(index <= @platos.length)
|
60
|
+
@platos[index].to_s
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
#Método que obtiene la descripción del plato del índice que se le pasa
|
65
|
+
def get_descripcion_plato(index)
|
66
|
+
if(index <= @platos.length)
|
67
|
+
@platos[index].descripcion
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
#Método que obtiene la porción del plato del índice que se le pasa
|
72
|
+
def get_porcion_plato(index)
|
73
|
+
if(index <= @platos.length)
|
74
|
+
@platos[index].porcion
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
#Método que obtiene la ingesta del plato del índice que se le pasa
|
79
|
+
def get_ingesta_plato(index)
|
80
|
+
if(index <= @platos.length)
|
81
|
+
@platos[index].ingesta
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
#Método que transforma menu a un string para mostrarlo
|
86
|
+
def to_s
|
87
|
+
i = 0
|
88
|
+
|
89
|
+
salida = "#{@titulo} (#{@porcentaje})\n"
|
90
|
+
while i < @platos.length do
|
91
|
+
salida += @platos[i].to_s + "\n"
|
92
|
+
i += 1
|
93
|
+
end
|
94
|
+
salida += "V.C.T. | % #{@calorias} Kcal | #{@porcentajeProteinas} - #{@porcentajeGrasas} - #{@porcentajeHidratos}"
|
95
|
+
|
96
|
+
salida
|
97
|
+
end
|
98
|
+
|
99
|
+
#Método para el módulo Comparable
|
100
|
+
def <=>(other)
|
101
|
+
raise TypeError "Se espera un Menu" unless other.is_a? MenuDieta
|
102
|
+
@calorias <=> other.calorias
|
103
|
+
end
|
104
|
+
|
105
|
+
#----------------------------------Setters-------------------------
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
#Método para asignar el porcentaje de proteinas
|
110
|
+
def setPorcentajeProteinas(porc)
|
111
|
+
@porcentajeProteinas = porc
|
112
|
+
end
|
113
|
+
|
114
|
+
#Método para asignar el porcentaje de grasas
|
115
|
+
def setPorcentajeGrasas(porc)
|
116
|
+
@porcentajeGrasas = porc
|
117
|
+
end
|
118
|
+
|
119
|
+
#Método para asignar el porcentaje de hidratos
|
120
|
+
def setPorcentajeHidratos(porc)
|
121
|
+
@porcentajeHidratos = porc
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#Clase para representar recetas de cocina según el tipo de alimento
|
2
|
+
|
3
|
+
class MenuAlimento < MenuDieta
|
4
|
+
|
5
|
+
attr_accessor :alimento
|
6
|
+
|
7
|
+
#Constructor
|
8
|
+
def initialize(titulo, porc, platos, calorias, porcentajesVCT, alimento)
|
9
|
+
super(titulo, porc, platos, calorias, porcentajesVCT)
|
10
|
+
@alimento = alimento
|
11
|
+
end
|
12
|
+
|
13
|
+
#Método para transformar en string la receta añadiendo el alimento
|
14
|
+
def to_s
|
15
|
+
super.to_s + "\nTipo de alimentos: " + @alimento
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#Clase para representar recetas de cocina con un formsto DSL
|
2
|
+
class MenuDSL
|
3
|
+
|
4
|
+
include Comparable
|
5
|
+
|
6
|
+
attr_accessor :etiqueta, :tituloMenu, :porcentaje, :platos, :vct, :porcProteinas, :porcGrasas, :porcHidratos
|
7
|
+
|
8
|
+
#Constructor de recetas
|
9
|
+
def initialize(etiqueta, &block)
|
10
|
+
@etiqueta = etiqueta
|
11
|
+
@tituloMenu
|
12
|
+
@porcentaje
|
13
|
+
@platos = []
|
14
|
+
@vct
|
15
|
+
|
16
|
+
if block_given?
|
17
|
+
if block.arity == 1
|
18
|
+
yield self
|
19
|
+
else
|
20
|
+
instance_eval(&block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
#Método para obtener el titulo de la recet
|
26
|
+
def titulo (titulo)
|
27
|
+
@tituloMenu = titulo
|
28
|
+
end
|
29
|
+
|
30
|
+
#Método para obtener el porcentaje de ingesta del menu
|
31
|
+
def ingesta(opciones = {})
|
32
|
+
|
33
|
+
if(opciones[:min] == opciones[:max])
|
34
|
+
@porcentaje = "(#{opciones[:min]}%)"
|
35
|
+
else
|
36
|
+
@porcentaje = "(#{opciones[:min]}% - #{opciones[:max]}%)"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
#Método para obtener un plato del menu
|
41
|
+
def plato(opciones = {})
|
42
|
+
plato = Plato.new(opciones[:descripcion], opciones[:porcion], "#{opciones[:gramos]} gramos")
|
43
|
+
|
44
|
+
platos << plato
|
45
|
+
end
|
46
|
+
|
47
|
+
#Método para obtener los porcentajes de proteinas, grasas e hidratos y el vct
|
48
|
+
def porcentajes(opciones = {})
|
49
|
+
@vct = "#{opciones[:vct]} Kcal"
|
50
|
+
@porcProteinas = "#{opciones[:proteinas]}%"
|
51
|
+
@porcGrasas = "#{opciones[:grasas]}%"
|
52
|
+
@porcHidratos = "#{opciones[:hidratos]}%"
|
53
|
+
end
|
54
|
+
|
55
|
+
#Método que transforma el menu a un string
|
56
|
+
def to_s
|
57
|
+
i = 0
|
58
|
+
|
59
|
+
salida = "#{@tituloMenu} (#{@porcentaje})\n"
|
60
|
+
while i < @platos.length do
|
61
|
+
salida += @platos[i].to_s + "\n"
|
62
|
+
i += 1
|
63
|
+
end
|
64
|
+
|
65
|
+
salida += "V.C.T. | % #{@calorias} | #{@porcProteinas} - #{@porcGrasas} - #{@porcHidratos}"
|
66
|
+
|
67
|
+
salida
|
68
|
+
end
|
69
|
+
|
70
|
+
#Método para el módulo Comparable
|
71
|
+
def <=>(other)
|
72
|
+
raise TypeError "Se espera un Menu" unless other.is_a? MenuDSL
|
73
|
+
@vct <=> other.vct
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#Clase para representar recetas de cocina según la edad
|
2
|
+
|
3
|
+
class MenuEdad < MenuDieta
|
4
|
+
|
5
|
+
attr_accessor :edad
|
6
|
+
|
7
|
+
#Constructor
|
8
|
+
def initialize(titulo, porc, platos, calorias, porcentajesVCT, edad)
|
9
|
+
super(titulo, porc, platos, calorias, porcentajesVCT)
|
10
|
+
@edad = edad
|
11
|
+
end
|
12
|
+
|
13
|
+
#Método para transformar en string la receta añadiendo la edad
|
14
|
+
def to_s
|
15
|
+
super.to_s + "\nEdad recomendada: " + @edad
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/lib/menu/plato.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#Clase para representar un plato perteneciente a una receta
|
2
|
+
|
3
|
+
class Plato
|
4
|
+
|
5
|
+
attr_accessor :descripcion, :porcion, :ingesta
|
6
|
+
|
7
|
+
#Constructor
|
8
|
+
def initialize(descripcion, porcion, ingesta)
|
9
|
+
@descripcion = descripcion
|
10
|
+
@porcion = porcion
|
11
|
+
@ingesta = ingesta
|
12
|
+
end
|
13
|
+
|
14
|
+
#Método que transforma a string un plato
|
15
|
+
def to_s
|
16
|
+
"- #{@descripcion}, #{@porcion}, #{@ingesta}"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/lib/menu/version.rb
ADDED
data/lib/menu.rb
ADDED
data/menu.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
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 = "menu_alu0100767803"
|
8
|
+
spec.version = Menu::VERSION
|
9
|
+
spec.authors = ["Jorge ALonso"]
|
10
|
+
spec.email = ["alu0100767803@ull.edu.es"]
|
11
|
+
|
12
|
+
spec.summary = %q{Gema para la creación de menús.}
|
13
|
+
spec.description = %q{Creación de menús con Ruby.}
|
14
|
+
spec.homepage = "https://github.com/ULL-ESIT-LPP-1617/tdd-menu-lpp-28.git"
|
15
|
+
####
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
####
|
19
|
+
|
20
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
21
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
22
|
+
=begin if spec.respond_to?(:metadata)
|
23
|
+
spec.metadata['allowed_push_host'] = "Set to 'http://mygemserver.com'"
|
24
|
+
else
|
25
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
26
|
+
"public gem pushes."
|
27
|
+
=end end
|
28
|
+
|
29
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
30
|
+
f.match(%r{^(test|spec|features)/})
|
31
|
+
end
|
32
|
+
spec.bindir = "exe"
|
33
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ["lib"]
|
35
|
+
|
36
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
37
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
38
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
39
|
+
spec.add_development_dependency "guard"
|
40
|
+
spec.add_development_dependency "guard-rspec"
|
41
|
+
spec.add_development_dependency "guard-bundler"
|
42
|
+
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: menu_alu0100767803
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jorge ALonso
|
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: Creación de menús con Ruby.
|
98
|
+
email:
|
99
|
+
- alu0100767803@ull.edu.es
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
|
+
- Gemfile
|
107
|
+
- Guardfile
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- bin/console
|
111
|
+
- bin/setup
|
112
|
+
- lib/menu.rb
|
113
|
+
- lib/menu/lista.rb
|
114
|
+
- lib/menu/menu.rb
|
115
|
+
- lib/menu/menu_alimento.rb
|
116
|
+
- lib/menu/menu_dsl.rb
|
117
|
+
- lib/menu/menu_edad.rb
|
118
|
+
- lib/menu/plato.rb
|
119
|
+
- lib/menu/version.rb
|
120
|
+
- menu.gemspec
|
121
|
+
homepage: https://github.com/ULL-ESIT-LPP-1617/tdd-menu-lpp-28.git
|
122
|
+
licenses: []
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 2.5.1
|
141
|
+
signing_key:
|
142
|
+
specification_version: 4
|
143
|
+
summary: Gema para la creación de menús.
|
144
|
+
test_files: []
|