Dieta-alu0100887778 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +5 -0
- data/Dieta.gemspec +36 -0
- data/Gemfile +4 -0
- data/Guardfile +82 -0
- data/README.md +36 -0
- data/Rakefile +12 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/Dieta/dieta_codigo.rb +113 -0
- data/lib/Dieta/dieta_dsl.rb +153 -0
- data/lib/Dieta/examen.rb +8 -0
- data/lib/Dieta/lista.rb +83 -0
- data/lib/Dieta/version.rb +3 -0
- data/lib/Dieta.rb +7 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 15eef6055127a728c0b6d6a9b638bc02eced32d1
|
4
|
+
data.tar.gz: 7e13b6d654d47f15946f5a28dcfb67091161b6c1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ac41906a9da638701b2b96b5868eddc9534685d7f0f0c11bbbded80417c405d2aa993d61e318b0319d2da11879f8867a9a2ee74b943ecc5af7d03cdad1ca4cc0
|
7
|
+
data.tar.gz: ca9efe88fd60ef3602cc1846833ff3e3c30e0786d737559956d01d30d6e709bfffbb5bc50ead8fea19eab38a5d2150828837748e875d2c71a67f9e0822b6cb61
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Dieta.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'Dieta/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "Dieta-alu0100887778"
|
8
|
+
spec.version = Dieta::VERSION
|
9
|
+
spec.authors = ["alu0100890839"]
|
10
|
+
spec.email = ["alu0100890839@ull.edu.es"]
|
11
|
+
|
12
|
+
spec.summary = %q{Practica 6 de LPP}
|
13
|
+
spec.homepage = "https://github.com/ULL-ESIT-LPP-1617/tdd-menu-equipo_44/"
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
##if spec.respond_to?(:metadata)
|
18
|
+
##spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
19
|
+
##else
|
20
|
+
##raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
21
|
+
#end
|
22
|
+
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
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.12"
|
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
|
+
|
35
|
+
|
36
|
+
end
|
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,36 @@
|
|
1
|
+
# Dieta
|
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/Dieta`. 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 'Dieta'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install Dieta
|
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]/Dieta.
|
36
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task :default => :spec
|
7
|
+
|
8
|
+
desc "Ejecutar las espectativas de la clase Lista"
|
9
|
+
task :spec do
|
10
|
+
sh "rspec -I. spec/Dieta_spec.rb spec/dieta_dslspec.rb"
|
11
|
+
|
12
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "Dieta"
|
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,113 @@
|
|
1
|
+
#Definimos el modulo Dieta
|
2
|
+
module Dieta
|
3
|
+
|
4
|
+
##Definimos la clase Dieta
|
5
|
+
class Dieta
|
6
|
+
|
7
|
+
##Incluimos el comparable
|
8
|
+
include Comparable
|
9
|
+
|
10
|
+
##Añadimos atributo de lectura
|
11
|
+
attr_reader :descripcion, :ingredientes, :informacion
|
12
|
+
|
13
|
+
|
14
|
+
#Incializamos las variables descripcion, ingredientes e informacion de la dieta
|
15
|
+
|
16
|
+
def initialize(descripcion, ingredientes, informacion, &block)
|
17
|
+
|
18
|
+
@descripcion=descripcion
|
19
|
+
@ingredientes=ingredientes
|
20
|
+
@informacion=informacion
|
21
|
+
end
|
22
|
+
|
23
|
+
##Definimos el metodo to_s de la Dieta
|
24
|
+
def to_s
|
25
|
+
output = @descripcion[0] + " | " + "#{@descripcion[1]}" + "%\n"
|
26
|
+
|
27
|
+
for i in 0..@ingredientes.size-1
|
28
|
+
output+="- " + @ingredientes[i][0] + ": " + " #{@ingredientes[i][1]}, " + " #{@ingredientes[i][2]} gramos \n"
|
29
|
+
end
|
30
|
+
|
31
|
+
output+= "V.C.T | % " + "#{@informacion[0]} " + "kcal | " + "#{@informacion[1]}% - #{@informacion[2]}% - #{@informacion[3]}%"
|
32
|
+
output
|
33
|
+
end
|
34
|
+
|
35
|
+
##Metodo para obtener la descripcion de la dieta
|
36
|
+
def get_desc
|
37
|
+
@descripcion[0]
|
38
|
+
end
|
39
|
+
##Metodo para obtener el porcentaje diario
|
40
|
+
def get_porcentaje_diario
|
41
|
+
@descripcion[1]
|
42
|
+
end
|
43
|
+
##Metodo para obtener el plato al que hace referencia la dieta
|
44
|
+
def get_plato(i)
|
45
|
+
@ingredientes[i]
|
46
|
+
end
|
47
|
+
##Metodo para obtener la lista de ingredientes
|
48
|
+
def get_ingredientes
|
49
|
+
@ingredientes
|
50
|
+
end
|
51
|
+
##Metodo para obtener el numero de calorías de la dieta
|
52
|
+
def get_vct
|
53
|
+
@informacion[0]
|
54
|
+
end
|
55
|
+
##Metodo para obtener el numero de proteinas de la dieta
|
56
|
+
def get_proteinas
|
57
|
+
@informacion[1]
|
58
|
+
end
|
59
|
+
##Metodo para obtener el numero de grasa de la dieta
|
60
|
+
def get_grasas
|
61
|
+
@informacion[2]
|
62
|
+
end
|
63
|
+
##Metodo para obtener el numero de hidratos de la dieta
|
64
|
+
def get_hidratos
|
65
|
+
@informacion[3]
|
66
|
+
end
|
67
|
+
##Metodo de obtencuon del listado de ingredientes y sus cantidades
|
68
|
+
def get_desc_plato(i)
|
69
|
+
@ingredientes[i][0] + ": " + " #{@ingredientes[i][1]}, " + " #{@ingredientes[i][2]} gramos"
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
##Metodo menor,mayor o igual del enumerable
|
74
|
+
def <=> (another)
|
75
|
+
get_vct <=> another.get_vct
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
##Subclase Menu_edad de la clase Dieta del modulo Dieta
|
83
|
+
class Menu_edad < Dieta::Dieta
|
84
|
+
|
85
|
+
|
86
|
+
##Añadimos atributo de lectura a la variable edad
|
87
|
+
attr_reader :edad
|
88
|
+
|
89
|
+
##Inicializacio de variables de la clase
|
90
|
+
def initialize(edad, dieta)
|
91
|
+
@edad = edad
|
92
|
+
super(dieta.descripcion, dieta.ingredientes, dieta.informacion)
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
##Subclase Menu_alimentos de la clase Dieta del modulo Dieta
|
100
|
+
|
101
|
+
class Menu_alimentos < Dieta::Dieta
|
102
|
+
|
103
|
+
##Añadimos atributo de lectura a la variable alimentos
|
104
|
+
attr_reader :alimentos
|
105
|
+
##Inicializacio de variables de la clase
|
106
|
+
def initialize(alimentos, dieta)
|
107
|
+
@alimentos = alimentos
|
108
|
+
super(dieta.descripcion, dieta.ingredientes, dieta.informacion)
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
|
@@ -0,0 +1,153 @@
|
|
1
|
+
class DietaDSL
|
2
|
+
|
3
|
+
##Incluimos el comparable
|
4
|
+
include Comparable
|
5
|
+
|
6
|
+
##Añadimos atributo de lectura
|
7
|
+
attr_reader :titulo, :nombre, :vct, :porcentaje_ingesta, :porcentajes,:platos
|
8
|
+
|
9
|
+
|
10
|
+
#Incializamos las variables descripcion, ingredientes e informacion de la dieta
|
11
|
+
|
12
|
+
def initialize(nombre, &block)
|
13
|
+
|
14
|
+
@nombre = nombre
|
15
|
+
@titulo = ""
|
16
|
+
@porcentajes = []
|
17
|
+
@porcentaje_ingesta = []
|
18
|
+
@vct= 0
|
19
|
+
@platos = []
|
20
|
+
|
21
|
+
if block_given?
|
22
|
+
if block.arity == 1
|
23
|
+
yield self
|
24
|
+
else
|
25
|
+
instance_eval(&block)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
##Definimos el metodo to_s de la Dieta
|
31
|
+
def to_s
|
32
|
+
output = @descripcion[0] + " | " + "#{@descripcion[1]}" + "%\n"
|
33
|
+
|
34
|
+
for i in 0..@ingredientes.size-1
|
35
|
+
output+="- " + @ingredientes[i][0] + ": " + " #{@ingredientes[i][1]}, " + " #{@ingredientes[i][2]} gramos \n"
|
36
|
+
end
|
37
|
+
|
38
|
+
output+= "V.C.T | % " + "#{@informacion[0]} " + "kcal | " + "#{@informacion[1]}% - #{@informacion[2]}% - #{@informacion[3]}%"
|
39
|
+
output
|
40
|
+
end
|
41
|
+
|
42
|
+
##Metodo para obtener la descripcion de la dieta
|
43
|
+
def get_desc
|
44
|
+
@descripcion[0]
|
45
|
+
end
|
46
|
+
##Metodo para obtener el porcentaje diario
|
47
|
+
def get_porcentaje_diario
|
48
|
+
@descripcion[1]
|
49
|
+
end
|
50
|
+
##Metodo para obtener el plato al que hace referencia la dieta
|
51
|
+
def get_plato(i)
|
52
|
+
@ingredientes[i]
|
53
|
+
end
|
54
|
+
##Metodo para obtener la lista de ingredientes
|
55
|
+
def get_ingredientes
|
56
|
+
@ingredientes
|
57
|
+
end
|
58
|
+
##Metodo para obtener el numero de calorías de la dieta
|
59
|
+
def get_vct
|
60
|
+
@informacion[0]
|
61
|
+
end
|
62
|
+
##Metodo para obtener el numero de proteinas de la dieta
|
63
|
+
def get_proteinas
|
64
|
+
@informacion[1]
|
65
|
+
end
|
66
|
+
##Metodo para obtener el numero de grasa de la dieta
|
67
|
+
def get_grasas
|
68
|
+
@informacion[2]
|
69
|
+
end
|
70
|
+
##Metodo para obtener el numero de hidratos de la dieta
|
71
|
+
def get_hidratos
|
72
|
+
@informacion[3]
|
73
|
+
end
|
74
|
+
##Metodo de obtencuon del listado de ingredientes y sus cantidades
|
75
|
+
def get_desc_plato(i)
|
76
|
+
@ingredientes[i][0] + ": " + " #{@ingredientes[i][1]}, " + " #{@ingredientes[i][2]} gramos"
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
##Metodo menor,mayor o igual del enumerable
|
81
|
+
def <=> (another)
|
82
|
+
get_vct <=> another.get_vct
|
83
|
+
end
|
84
|
+
|
85
|
+
def titulo_ (name)
|
86
|
+
@titulo = name
|
87
|
+
end
|
88
|
+
|
89
|
+
def plato_(opciones={})
|
90
|
+
gramos=""
|
91
|
+
descripcion= ""
|
92
|
+
porcion= ""
|
93
|
+
gramos = "#{opciones[:gramos]}" if opciones[:gramos]
|
94
|
+
descripcion = opciones[:descripcion] if opciones [:descripcion]
|
95
|
+
porcion= opciones[:porcion] if opciones[:porcion]
|
96
|
+
|
97
|
+
@platos.push([descripcion,porcion,gramos])
|
98
|
+
end
|
99
|
+
|
100
|
+
def ingesta_(opciones={})
|
101
|
+
ingesta = ""
|
102
|
+
ingesta <<"#{opciones[:min]}" if opciones[:min]
|
103
|
+
ingesta << "#{opciones[:max]}" if opciones[:max]
|
104
|
+
@porcentaje_ingesta = ingesta
|
105
|
+
end
|
106
|
+
|
107
|
+
def porcentajes_(opciones={})
|
108
|
+
proteinas= ""
|
109
|
+
grasas= ""
|
110
|
+
hidratos= ""
|
111
|
+
@vct = opciones[:vct] if opciones[:vct]
|
112
|
+
proteinas = opciones[:proteinas] if opciones[:proteinas]
|
113
|
+
hidratos = opciones[:hidratos] if opciones[:hidratos]
|
114
|
+
grasas = opciones[:grasas] if opciones[:grasas]
|
115
|
+
@porcentajes.push(hidratos)
|
116
|
+
@porcentajes.push(proteinas)
|
117
|
+
@porcentajes.push(grasas)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
##Subclase Menu_edad de la clase Dieta del modulo Dieta
|
123
|
+
class Menu_edad < Dieta::Dieta
|
124
|
+
|
125
|
+
|
126
|
+
##Añadimos atributo de lectura a la variable edad
|
127
|
+
attr_reader :edad
|
128
|
+
|
129
|
+
##Inicializacio de variables de la clase
|
130
|
+
def initialize(edad, dieta)
|
131
|
+
@edad = edad
|
132
|
+
super(dieta.descripcion, dieta.ingredientes, dieta.informacion)
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
##Subclase Menu_alimentos de la clase Dieta del modulo Dieta
|
140
|
+
|
141
|
+
class Menu_alimentos < Dieta::Dieta
|
142
|
+
|
143
|
+
##Añadimos atributo de lectura a la variable alimentos
|
144
|
+
attr_reader :alimentos
|
145
|
+
##Inicializacio de variables de la clase
|
146
|
+
def initialize(alimentos, dieta)
|
147
|
+
@alimentos = alimentos
|
148
|
+
super(dieta.descripcion, dieta.ingredientes, dieta.informacion)
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
|
data/lib/Dieta/examen.rb
ADDED
data/lib/Dieta/lista.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
##Creamos la estructura de un nodo nuevo, con su valor, su nodo siguiente y su nodo rpevio
|
2
|
+
Nodo = Struct.new(:valor, :siguiente, :prev)
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
##Definicion de la Clase Lista
|
7
|
+
class Lista
|
8
|
+
|
9
|
+
##Incluimos el Enumerable
|
10
|
+
include Enumerable
|
11
|
+
|
12
|
+
##Añadimos atributo de lectura
|
13
|
+
attr_reader :cabecera, :cola
|
14
|
+
|
15
|
+
|
16
|
+
##Inicializamos la cabecera y la cola de la lista a nulo
|
17
|
+
def initialize
|
18
|
+
|
19
|
+
@cabecera = nil
|
20
|
+
@cola= nil
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
##Metodo push de a lista que introduce los valores dentro de la misma
|
25
|
+
|
26
|
+
def push (valores)
|
27
|
+
if(valores.instance_of? Array)
|
28
|
+
if(@cola == nil)
|
29
|
+
|
30
|
+
@cola = Nodo.new(valores[0],nil,nil)
|
31
|
+
@cabecera = @cola
|
32
|
+
valores.shift()
|
33
|
+
end
|
34
|
+
|
35
|
+
valores.each do |valor|
|
36
|
+
aux= @cabecera
|
37
|
+
@cabecera = Nodo.new(valor,nil,aux)
|
38
|
+
aux.siguiente= @cabecera
|
39
|
+
end
|
40
|
+
else
|
41
|
+
|
42
|
+
if(@cola==nil)
|
43
|
+
@cola = Nodo.new(valores,nil,nil)
|
44
|
+
@cabecera = @cola
|
45
|
+
else
|
46
|
+
aux= @cabecera
|
47
|
+
@cabecera = Nodo.new(valores,nil,aux)
|
48
|
+
aux.siguiente= @cabecera
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
##Funcion pop que devuelve el valor de la cabecera y la elimina de la lista
|
55
|
+
def pop
|
56
|
+
if(@cabecera!=nil)
|
57
|
+
node = @cabecera
|
58
|
+
@cabecera = @cabecera.prev
|
59
|
+
if(@cabecera!=nil)
|
60
|
+
@cabecera.siguiente = nil
|
61
|
+
node.prev= nil
|
62
|
+
else @cola = nil
|
63
|
+
end
|
64
|
+
return node.valor
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
## Metodo each para el enumerable
|
71
|
+
|
72
|
+
def each
|
73
|
+
nodo = @cola
|
74
|
+
while(nodo != nil)
|
75
|
+
yield nodo.valor
|
76
|
+
nodo = nodo.siguiente
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
|
data/lib/Dieta.rb
ADDED
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Dieta-alu0100887778
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- alu0100890839
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-14 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.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
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:
|
98
|
+
email:
|
99
|
+
- alu0100890839@ull.edu.es
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
|
+
- Dieta.gemspec
|
107
|
+
- Gemfile
|
108
|
+
- Guardfile
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
113
|
+
- lib/Dieta.rb
|
114
|
+
- lib/Dieta/dieta_codigo.rb
|
115
|
+
- lib/Dieta/dieta_dsl.rb
|
116
|
+
- lib/Dieta/examen.rb
|
117
|
+
- lib/Dieta/lista.rb
|
118
|
+
- lib/Dieta/version.rb
|
119
|
+
homepage: https://github.com/ULL-ESIT-LPP-1617/tdd-menu-equipo_44/
|
120
|
+
licenses: []
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.5.1
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Practica 6 de LPP
|
142
|
+
test_files: []
|