menualu0100782851 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 +8 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/Guardfile +82 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/prct11.rb +5 -0
- data/lib/prct11/dieta.rb +23 -0
- data/lib/prct11/lista.rb +111 -0
- data/lib/prct11/menu.rb +79 -0
- data/lib/prct11/menu_alimentos.rb +16 -0
- data/lib/prct11/menu_dsl.rb +68 -0
- data/lib/prct11/menu_edad.rb +16 -0
- data/lib/prct11/plato.rb +17 -0
- data/lib/prct11/prueba.rb +56 -0
- data/lib/prct11/version.rb +3 -0
- data/prct11.gemspec +39 -0
- metadata +147 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: a24a13db736059e01d1312d9ecff8202be53ac3e
|
|
4
|
+
data.tar.gz: dc8dd83f36cb2a42c3386408dd84ffd48c7277f1
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 452dc08b525c37af587c87ca66835bf560366f95d4cdee91e2fbc52887be0d7269bffc6ee365edd17d062d0e75913fe6e479b3b4dd3be3116a96d9e2117fb55e
|
|
7
|
+
data.tar.gz: 247507acc4b490daf04bac669dc27967a055c08320d5522d74e2083455bc9ef827124f716c7e722ece8aa975b9d9802a7ec238f6c07e6e7677382545ada44b88
|
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
|
+
# Prct11
|
|
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/prct09`. 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 'prct09'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install prct09
|
|
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]/prct09. 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 "prct11"
|
|
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/prct11.rb
ADDED
data/lib/prct11/dieta.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#require './menu'
|
|
2
|
+
|
|
3
|
+
class Dieta
|
|
4
|
+
|
|
5
|
+
attr_accessor :menus #geters y setters asi nos ahorramos escribirlo
|
|
6
|
+
|
|
7
|
+
def initialize(menus)
|
|
8
|
+
@menus = menus
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def to_s
|
|
13
|
+
string =""
|
|
14
|
+
@menus.each_with_index do |elem, i|
|
|
15
|
+
string+="#{elem.to_s}\n\n" #llama al metodo to_s de la clase menu
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
return string
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
|
data/lib/prct11/lista.rb
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Nodo = Struct.new(:value, :siguiente, :previo)
|
|
2
|
+
|
|
3
|
+
class Lista
|
|
4
|
+
|
|
5
|
+
attr_accessor :head, :tail, :contador
|
|
6
|
+
include Enumerable
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
@head = Nodo.new(nil,nil,nil) #inicio de la lista
|
|
10
|
+
@tail = Nodo.new(nil,nil,nil) #fin de la lista
|
|
11
|
+
@contador=0 #variable que determina el tamaño actual de la lista
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def insert_head(nodo)
|
|
16
|
+
|
|
17
|
+
if empty == true #Si la lista esta vacia insertamos el elemento en la lista vacia
|
|
18
|
+
nodo[:previo] = @tail
|
|
19
|
+
nodo[:siguiente] = @head
|
|
20
|
+
@head = nodo
|
|
21
|
+
@tail = nodo
|
|
22
|
+
else #Si no esta vacia insertamos por el head
|
|
23
|
+
nodo[:previo] = @head
|
|
24
|
+
nodo[:siguiente] = nil
|
|
25
|
+
@head[:siguiente] = nodo
|
|
26
|
+
@head = nodo
|
|
27
|
+
end
|
|
28
|
+
@contador = @contador + 1 #Aumentamos variable que indica tamaño de la lista
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def insert_tail(nodo)
|
|
33
|
+
if empty #Si esta vacia insertamos en lista vacia
|
|
34
|
+
insert_head(nodo)
|
|
35
|
+
else #Si no insertamos por el tail
|
|
36
|
+
nodo[:siguiente] = @tail
|
|
37
|
+
nodo[:previo] = nil
|
|
38
|
+
@tail[:previo] = nodo
|
|
39
|
+
@tail = nodo
|
|
40
|
+
@contador = @contador + 1
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def extract_head
|
|
46
|
+
aux = @head
|
|
47
|
+
@head = @head[:previo]
|
|
48
|
+
|
|
49
|
+
if @head != nil #Si head no es nil ponemos el siguiente de head como nil para desenlazar la lista
|
|
50
|
+
@head[:siguiente] = nil
|
|
51
|
+
else #Si el elemento que se extrae es el unico de la lista entonces ponemos todo a nil como en initialize
|
|
52
|
+
@tail = nil
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
@contador = @contador - 1
|
|
56
|
+
return aux.value
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def extract_tail
|
|
61
|
+
if @contador == 1
|
|
62
|
+
return extract_head
|
|
63
|
+
else
|
|
64
|
+
actual = @tail
|
|
65
|
+
@tail = @tail[:siguiente]
|
|
66
|
+
|
|
67
|
+
if @tail != nil
|
|
68
|
+
@tail[:previo] = nil
|
|
69
|
+
end
|
|
70
|
+
@contador = @contador - 1
|
|
71
|
+
return actual.value
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def insert_varios (nodos)
|
|
77
|
+
for i in 0..(nodos.length - 1)
|
|
78
|
+
insert_head(nodos[i])
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def to_s
|
|
84
|
+
aux = @tail
|
|
85
|
+
if empty != true
|
|
86
|
+
string= "\n****** MENU DIETETICO ******"
|
|
87
|
+
while aux.siguiente != nil
|
|
88
|
+
string+= "\n\n#{aux.value}"
|
|
89
|
+
aux = aux.siguiente
|
|
90
|
+
end
|
|
91
|
+
string += "\n\n#{aux.value}"
|
|
92
|
+
return string
|
|
93
|
+
else
|
|
94
|
+
return "Lista vacia"
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def each
|
|
99
|
+
actual = @tail
|
|
100
|
+
|
|
101
|
+
while actual != nil
|
|
102
|
+
yield actual.value
|
|
103
|
+
actual = actual.siguiente
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def empty
|
|
108
|
+
return contador==0
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
end
|
data/lib/prct11/menu.rb
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
class Menu
|
|
2
|
+
|
|
3
|
+
attr_accessor :titulo, :ingestaPor, :platos, :valorCT, :porcentajePro, :porcentajeGra, :porcentajeHid #geters y setters asi nos ahorramos escribirlo
|
|
4
|
+
|
|
5
|
+
include Comparable
|
|
6
|
+
|
|
7
|
+
def initialize(titulo, ingestaPor, platos, valorCT, porcentajePro, porcentajeGra, porcentajeHid)
|
|
8
|
+
@titulo = titulo
|
|
9
|
+
@ingestaPor = ingestaPor
|
|
10
|
+
@platos = platos
|
|
11
|
+
@valorCT = valorCT
|
|
12
|
+
@porcentajePro = porcentajePro
|
|
13
|
+
@porcentajeGra = porcentajeGra
|
|
14
|
+
@porcentajeHid = porcentajeHid
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def <=>(other)
|
|
19
|
+
|
|
20
|
+
return nil unless other.is_a?Menu #Devuelve nil si se cumple que other no es un objeto de tipo bibliografia
|
|
21
|
+
|
|
22
|
+
if(@valorCT[0] == other.valorCT[0])
|
|
23
|
+
|
|
24
|
+
if(@platos.length == other.platos.length)
|
|
25
|
+
return 0
|
|
26
|
+
else
|
|
27
|
+
if(@platos.length < other.platos.length)
|
|
28
|
+
return -1
|
|
29
|
+
end
|
|
30
|
+
return 1
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
else
|
|
34
|
+
if(@valorCT[0] < other.valorCT[0])
|
|
35
|
+
return -1
|
|
36
|
+
end
|
|
37
|
+
return 1
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def ==(other)
|
|
42
|
+
|
|
43
|
+
if other.is_a?Menu
|
|
44
|
+
@titulo == other.titulo &&
|
|
45
|
+
@ingestaPor == other.ingestaPor &&
|
|
46
|
+
@platos == other.platos &&
|
|
47
|
+
@valorCT == other.valorCT &&
|
|
48
|
+
@porcentajePro == other.porcentajePro &&
|
|
49
|
+
@porcentajeGra == other.porcentajeGra &&
|
|
50
|
+
@porcentajeHid == other.porcentajeHid
|
|
51
|
+
else
|
|
52
|
+
false
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def to_s
|
|
59
|
+
string = "#{@titulo} ("
|
|
60
|
+
|
|
61
|
+
@ingestaPor.each_with_index do |elem,i|
|
|
62
|
+
if(i==1)
|
|
63
|
+
string+=" - "
|
|
64
|
+
end
|
|
65
|
+
string+= "#{elem}"
|
|
66
|
+
end
|
|
67
|
+
string+="%)\n"
|
|
68
|
+
|
|
69
|
+
@platos.each_with_index do |elem,i|
|
|
70
|
+
string+="- #{elem.to_s}\n"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
string+="V.C.T. | % #{valorCT[0]} #{valorCT[1]} | #{porcentajePro}% - #{porcentajeGra}% - #{porcentajeHid}%"
|
|
74
|
+
|
|
75
|
+
return string
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
class Menu_alimentos < Menu
|
|
3
|
+
attr_accessor :alimentos
|
|
4
|
+
|
|
5
|
+
def initialize(titulo, ingestaPor, platos, valorCT, porcentajePro, porcentajeGra, porcentajeHid, alimentos)
|
|
6
|
+
|
|
7
|
+
super(titulo, ingestaPor, platos, valorCT, porcentajePro, porcentajeGra, porcentajeHid)
|
|
8
|
+
@alimentos = alimentos
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def to_s
|
|
12
|
+
string = "Menu de: #{@alimentos}\n" + super.to_s
|
|
13
|
+
return string
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
class Menu_dsl
|
|
2
|
+
attr_accessor :etiqueta, :titulo, :ingesta, :plato, :porcentaje
|
|
3
|
+
|
|
4
|
+
def initialize(etiqueta, &block)
|
|
5
|
+
self.etiqueta = etiqueta
|
|
6
|
+
|
|
7
|
+
self.titulo = ""
|
|
8
|
+
self.ingesta = []
|
|
9
|
+
self.plato = []
|
|
10
|
+
self.porcentaje = []
|
|
11
|
+
|
|
12
|
+
if block_given?
|
|
13
|
+
if block.arity == 1
|
|
14
|
+
yield self
|
|
15
|
+
else
|
|
16
|
+
instance_eval(&block)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def titulos(options = {})
|
|
23
|
+
titulo << "#{options[:titulo]}"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def ingestas(options = {})
|
|
27
|
+
ingesta << "#{options[:max]}" if options[:max]
|
|
28
|
+
ingesta << "#{options[:min]}" if options[:min]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def platos(options = {})
|
|
32
|
+
pl = []
|
|
33
|
+
pl << "#{options[:descPlato]}" if options[:descPlato]
|
|
34
|
+
pl << "#{options[:descPorcion]}" if options[:descPorcion]
|
|
35
|
+
pl << "#{options[:ingestaGramos]}" if options[:ingestaGramos]
|
|
36
|
+
|
|
37
|
+
plato << pl
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def porcentajes(options = {})
|
|
41
|
+
pc = []
|
|
42
|
+
pc << "#{options[:vct]}" if options[:vct]
|
|
43
|
+
pc << "#{options[:proteinas]}" if options[:proteinas]
|
|
44
|
+
pc << "#{options[:grasas]}" if options[:grasas]
|
|
45
|
+
pc << "#{options[:hidratos]}" if options[:hidratos]
|
|
46
|
+
|
|
47
|
+
porcentaje << pc
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def to_s
|
|
51
|
+
output = etiqueta
|
|
52
|
+
output << "\n#{'=' * etiqueta.size}\n\n"
|
|
53
|
+
|
|
54
|
+
output << "#{titulo}"
|
|
55
|
+
output << "(#{ingesta[0]} - #{ingesta[1]}%) \n"
|
|
56
|
+
|
|
57
|
+
plato.each_with_index do |plato, index|
|
|
58
|
+
output << "- #{plato[0]}, #{plato[1]}, #{plato[2]}g\n"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
porcentaje.each_with_index do |porcentaje, index|
|
|
62
|
+
output << "V.C.T. | % #{porcentaje[0]}Kcal | #{porcentaje[1]}% - #{porcentaje[2]}% - #{porcentaje[3]}%\n"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
output
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
class Menu_edad < Menu
|
|
3
|
+
attr_accessor :edad
|
|
4
|
+
|
|
5
|
+
def initialize(titulo, ingestaPor, platos, valorCT, porcentajePro, porcentajeGra, porcentajeHid, edad)
|
|
6
|
+
|
|
7
|
+
super(titulo, ingestaPor, platos, valorCT, porcentajePro, porcentajeGra, porcentajeHid)
|
|
8
|
+
@edad = edad
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def to_s
|
|
12
|
+
string = "Menu para edades entre: [#{edad[0]} - #{edad[1]}] años\n" + super.to_s
|
|
13
|
+
return string
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
data/lib/prct11/plato.rb
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class Plato
|
|
2
|
+
|
|
3
|
+
attr_accessor :descPlato, :descPorcion, :ingestaGramos #geters y serters asi nos ahorramos escribirlo
|
|
4
|
+
|
|
5
|
+
def initialize(descPlato, descPorcion, ingestaGramos)
|
|
6
|
+
@descPlato = descPlato
|
|
7
|
+
@descPorcion = descPorcion
|
|
8
|
+
@ingestaGramos = ingestaGramos
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def to_s
|
|
13
|
+
string ="#{descPlato}, #{descPorcion[0]} #{descPorcion[1]}, #{ingestaGramos} g"
|
|
14
|
+
return string
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
class Recipe
|
|
2
|
+
attr_accessor :name, :ingredients, :instructions
|
|
3
|
+
|
|
4
|
+
def initialize(name, &block)
|
|
5
|
+
self.name = name
|
|
6
|
+
self.ingredients = []
|
|
7
|
+
self.instructions = []
|
|
8
|
+
|
|
9
|
+
instance_eval &block
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def to_s
|
|
13
|
+
output << "EORECIPE #{name} #{'=' * name.size} Ingredients: #{ingredients.join(', ')}
|
|
14
|
+
|
|
15
|
+
#{ out = ""
|
|
16
|
+
instructions.each_with_index do |instruction, index|
|
|
17
|
+
out << "#{index + 1}) #{instruction}\n"
|
|
18
|
+
end
|
|
19
|
+
out
|
|
20
|
+
}
|
|
21
|
+
EORECIPE"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def ingredient(name, options = {})
|
|
25
|
+
ingredient = name
|
|
26
|
+
ingredient << " (#{options[:amount]})" if options[:amount]
|
|
27
|
+
|
|
28
|
+
ingredients << ingredient
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def step(text, options = {})
|
|
32
|
+
instruction = text
|
|
33
|
+
instruction << " (#{options[:for]})" if options[:for]
|
|
34
|
+
|
|
35
|
+
instructions << instruction
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def amount
|
|
39
|
+
:amount
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def during
|
|
43
|
+
:for
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
puts Recipe.new("Noodles and Cheese") {
|
|
48
|
+
ingredient "Water", amount => "2 cups"
|
|
49
|
+
ingredient "Noodles", amount => "1 cup"
|
|
50
|
+
ingredient "Cheese", amount => "1/2 cup"
|
|
51
|
+
|
|
52
|
+
step "Heat water to boiling.", during => "5 minutes"
|
|
53
|
+
step "Add noodles to boiling water.", during => "6 minutes"
|
|
54
|
+
step "Drain water."
|
|
55
|
+
step "Mix cheese in with noodles."
|
|
56
|
+
}
|
data/prct11.gemspec
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'prct11/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "menualu0100782851"
|
|
8
|
+
spec.version = Prct11::VERSION
|
|
9
|
+
spec.authors = ["Moises Yanes Carballo"]
|
|
10
|
+
spec.email = ["alu0100782851@ull.edu.es"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{DSL en ruby}
|
|
13
|
+
spec.description = %q{Creacion de dsl en ruby}
|
|
14
|
+
spec.homepage = "https://github.com/ULL-ESIT-LPP-1617/menu-dietetico-alu0100782851/tree/master"
|
|
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 if spec.respond_to?(:metadata)
|
|
20
|
+
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
|
21
|
+
else
|
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
23
|
+
"public gem pushes."
|
|
24
|
+
end
|
|
25
|
+
=end
|
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
|
28
|
+
end
|
|
29
|
+
spec.bindir = "exe"
|
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
31
|
+
spec.require_paths = ["lib"]
|
|
32
|
+
|
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
36
|
+
spec.add_development_dependency "guard"
|
|
37
|
+
spec.add_development_dependency "guard-rspec"
|
|
38
|
+
spec.add_development_dependency "guard-bundler"
|
|
39
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: menualu0100782851
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Moises Yanes Carballo
|
|
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: Creacion de dsl en ruby
|
|
98
|
+
email:
|
|
99
|
+
- alu0100782851@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/prct11.rb
|
|
113
|
+
- lib/prct11/dieta.rb
|
|
114
|
+
- lib/prct11/lista.rb
|
|
115
|
+
- lib/prct11/menu.rb
|
|
116
|
+
- lib/prct11/menu_alimentos.rb
|
|
117
|
+
- lib/prct11/menu_dsl.rb
|
|
118
|
+
- lib/prct11/menu_edad.rb
|
|
119
|
+
- lib/prct11/plato.rb
|
|
120
|
+
- lib/prct11/prueba.rb
|
|
121
|
+
- lib/prct11/version.rb
|
|
122
|
+
- prct11.gemspec
|
|
123
|
+
homepage: https://github.com/ULL-ESIT-LPP-1617/menu-dietetico-alu0100782851/tree/master
|
|
124
|
+
licenses:
|
|
125
|
+
- MIT
|
|
126
|
+
metadata: {}
|
|
127
|
+
post_install_message:
|
|
128
|
+
rdoc_options: []
|
|
129
|
+
require_paths:
|
|
130
|
+
- lib
|
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
|
+
requirements:
|
|
133
|
+
- - ">="
|
|
134
|
+
- !ruby/object:Gem::Version
|
|
135
|
+
version: '0'
|
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
|
+
requirements:
|
|
138
|
+
- - ">="
|
|
139
|
+
- !ruby/object:Gem::Version
|
|
140
|
+
version: '0'
|
|
141
|
+
requirements: []
|
|
142
|
+
rubyforge_project:
|
|
143
|
+
rubygems_version: 2.5.1
|
|
144
|
+
signing_key:
|
|
145
|
+
specification_version: 4
|
|
146
|
+
summary: DSL en ruby
|
|
147
|
+
test_files: []
|