dieta_alu0100618426 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/.coveralls.yml +1 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Guardfile +82 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/dieta.gemspec +41 -0
- data/lib/dieta/dieta_m.rb +171 -0
- data/lib/dieta/lista.rb +86 -0
- data/lib/dieta/version.rb +6 -0
- data/lib/dieta.rb +7 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 14a23edb416cbacb975209dd6a25471b065c9ef5
|
4
|
+
data.tar.gz: ffbdcb1b65d254f19f1aad36d448584c34089c3a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cbc653c3a0ff6b1c3a44a0385ab576ddb67c91d45ee9caba3c8108e008fc87f06a941398971b577538f863b8a74db2ed07775a9832edb9b745469d6967eddcbe
|
7
|
+
data.tar.gz: 84fc5924660d29c809f41437960f5d9af4b4b3a87788b5c9fe7aceb23867603495bfa6bd0b3f8bac15a934dcd08455e8e4a5f403f58f8b5aaaaac912862edc1d
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 alu0100618426@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
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 Airam Navas
|
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
|
+
# 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. 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 "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
data/dieta.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
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_alu0100618426"
|
8
|
+
spec.version = Dieta::VERSION
|
9
|
+
spec.authors = ["Airam Navas"]
|
10
|
+
spec.email = ["alu0100618426@ull.edu.es"]
|
11
|
+
|
12
|
+
spec.summary = %q{Práctica 08}
|
13
|
+
spec.description = %q{Clase menu para dietas recomendadas.}
|
14
|
+
spec.homepage = "https://github.com/ULL-ESIT-LPP-1617/menu-dietetico-AiramNavas.git"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
|
20
|
+
#if spec.respond_to?(:metadata)
|
21
|
+
# spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
22
|
+
#else
|
23
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
24
|
+
# "public gem pushes."
|
25
|
+
#end
|
26
|
+
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
28
|
+
f.match(%r{^(test|spec|features)/})
|
29
|
+
end
|
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
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
module Dieta
|
2
|
+
# Clase menú
|
3
|
+
class Menu
|
4
|
+
|
5
|
+
include Comparable
|
6
|
+
|
7
|
+
# Variable que almacena el título del menú
|
8
|
+
attr_accessor :titulo
|
9
|
+
# Array que almacena los porcentajes del menú en concreto
|
10
|
+
attr_accessor :porcentaje
|
11
|
+
# Array que almacena los platos que forman parte del menú
|
12
|
+
attr_accessor :platos
|
13
|
+
# Variable que almacena la información de VCT del manú
|
14
|
+
attr_accessor :VCT
|
15
|
+
# Variable que almacena la información de las kilocalorias del manú
|
16
|
+
attr_accessor :kilocalorias
|
17
|
+
# Variable que almacena la información de las proteínas del manú
|
18
|
+
attr_accessor :proteinas
|
19
|
+
# Variable que almacena la información de las grasas del manú
|
20
|
+
attr_accessor :grasas
|
21
|
+
# Variable que almacena la información de los hidratos del manú
|
22
|
+
attr_accessor :hidratos
|
23
|
+
|
24
|
+
# Inicializa la lista
|
25
|
+
def initialize(cabecera, platos, informacion)
|
26
|
+
|
27
|
+
@titulo = cabecera[0]
|
28
|
+
@porcentaje = cabecera[1].to_s + "-" + cabecera[2].to_s + "%"
|
29
|
+
@platos = platos
|
30
|
+
@VCT = informacion[0]
|
31
|
+
@kilocalorias = informacion[1]
|
32
|
+
@proteinas = informacion[2]
|
33
|
+
@grasas = informacion[3]
|
34
|
+
@hidratos = informacion[4]
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
# Devuelve un plato que contiene un array de elementos
|
39
|
+
# @param numero el número del plato en concreto
|
40
|
+
def get_plato(numero)
|
41
|
+
@platos[numero]
|
42
|
+
end
|
43
|
+
|
44
|
+
# Devuelve la descripción del plato
|
45
|
+
# @param numero el número del plato en concreto
|
46
|
+
def get_descripcion(numero)
|
47
|
+
@platos[numero][0]
|
48
|
+
end
|
49
|
+
|
50
|
+
# Devuelve la porción del plato
|
51
|
+
# @param numero el número del plato en concreto
|
52
|
+
def get_porcion(numero)
|
53
|
+
@platos[numero][1]
|
54
|
+
end
|
55
|
+
|
56
|
+
# Devuelve la ingesta del plato
|
57
|
+
# @param numero el número del plato en concreto
|
58
|
+
def get_ingesta(numero)
|
59
|
+
@platos[numero][2]
|
60
|
+
end
|
61
|
+
|
62
|
+
# Devuelve el array de los platos
|
63
|
+
def get_pt
|
64
|
+
@platos
|
65
|
+
end
|
66
|
+
|
67
|
+
# Compara la cantidad de platos entre dos menús
|
68
|
+
# @param anOther otro elemento menú con el que comparar
|
69
|
+
def <=>(anOther)
|
70
|
+
@platos.length <=> anOther.get_pt.length
|
71
|
+
end
|
72
|
+
|
73
|
+
# Método a string
|
74
|
+
def to_s
|
75
|
+
|
76
|
+
mostrar = "#{@titulo} (#{@porcentaje})\n"
|
77
|
+
|
78
|
+
i = 0;
|
79
|
+
while i < @platos.length
|
80
|
+
mostrar += "- #{@platos[i][0]}, #{platos[i][1]}, #{platos[i][2]}\n"
|
81
|
+
i+=1
|
82
|
+
end
|
83
|
+
|
84
|
+
mostrar += "V.C.T. #{@VCT} #{@kilocalorias} kcal | #{@proteinas}% - #{@grasas}% - #{@hidratos}%\n"
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
#Clase GruposAlimentos que hereda de Menu para agregar grupos de alimentos
|
91
|
+
class GruposAlimentos < Menu
|
92
|
+
# Variable utilizada para agregar el grupo de alimento a los menús
|
93
|
+
attr_reader :grupoAlimento
|
94
|
+
|
95
|
+
# Inicializa la lista
|
96
|
+
def initialize(grupoAlimento, cabecera, platos, informacion)
|
97
|
+
super(cabecera, platos, informacion)
|
98
|
+
@grupoAlimento = grupoAlimento
|
99
|
+
end
|
100
|
+
|
101
|
+
# Devuelve el grupo de alimento al que pertenezca
|
102
|
+
def get_grupoA
|
103
|
+
@grupoAlimento
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
#Clase GruposEdad que hereda de Menu para agregar grupos de edades
|
109
|
+
class GruposEdad < Menu
|
110
|
+
# Variable utilizada para agregar el grupo de edades a los menús
|
111
|
+
attr_reader :grupoEdad
|
112
|
+
|
113
|
+
# Inicializa la lista
|
114
|
+
def initialize(grupoEdad, cabecera, platos, informacion)
|
115
|
+
super(cabecera, platos, informacion)
|
116
|
+
@grupoEdad = grupoEdad
|
117
|
+
end
|
118
|
+
|
119
|
+
# Devuelve el grupo de edad al que pertenezca
|
120
|
+
def get_grupoE
|
121
|
+
@grupoEdad
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
class Menu_DSL < Menu
|
128
|
+
|
129
|
+
def initialize(tag, &block)
|
130
|
+
super([], [], [])
|
131
|
+
|
132
|
+
if block_given?
|
133
|
+
if block.arity == 1
|
134
|
+
yield self
|
135
|
+
else
|
136
|
+
instance_eval(&block)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def titulo(name)
|
142
|
+
@titulo = name
|
143
|
+
end
|
144
|
+
|
145
|
+
def ingesta(options = {})
|
146
|
+
@porcentaje = "#{options[:min]}"
|
147
|
+
if options[:max]
|
148
|
+
@porcentaje += "-#{options[:max]}"
|
149
|
+
end
|
150
|
+
@porcentaje += "%"
|
151
|
+
end
|
152
|
+
|
153
|
+
def plato(options = {})
|
154
|
+
plato = [];
|
155
|
+
plato << options[:description]
|
156
|
+
plato << options[:porcion]
|
157
|
+
plato << options[:gramos].to_s
|
158
|
+
|
159
|
+
@platos << plato
|
160
|
+
end
|
161
|
+
|
162
|
+
def porcentajes(options = {})
|
163
|
+
@VCT = options[:vct].to_s
|
164
|
+
@proteinas = options[:proteinas].to_s
|
165
|
+
@grasas = options[:grasas].to_s
|
166
|
+
@hidratos = options[:hidratos].to_s
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
data/lib/dieta/lista.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
require "dieta/dieta_m"
|
2
|
+
|
3
|
+
module Lista
|
4
|
+
|
5
|
+
# @attr [Object] value Objeto contenido en el nodo
|
6
|
+
# @attr [Node] next Nodo siguiente
|
7
|
+
# @attr [Node] prev Nodo previo
|
8
|
+
Node = Struct.new(:value, :next, :prev)
|
9
|
+
|
10
|
+
class MD_list
|
11
|
+
|
12
|
+
include Enumerable
|
13
|
+
|
14
|
+
# Variable que almacena la nodo cabeza (primero) de la lista
|
15
|
+
attr_accessor :head
|
16
|
+
# Variable que almacena la nodo cola (final) de la lista
|
17
|
+
attr_accessor :tail
|
18
|
+
|
19
|
+
# Inicializa la lista
|
20
|
+
def initialize()
|
21
|
+
|
22
|
+
@head = nil
|
23
|
+
@tail = nil
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
# Extrae el primer nodo
|
28
|
+
def extract_first
|
29
|
+
|
30
|
+
nodo = @head
|
31
|
+
|
32
|
+
if nodo != nil
|
33
|
+
if nodo.next != nil
|
34
|
+
@head = nodo.next
|
35
|
+
else
|
36
|
+
@head = nil
|
37
|
+
@tail = nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
nodo
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
# Inserta un nodo
|
46
|
+
# @param node el nodo que quieras insertar
|
47
|
+
def insert(node)
|
48
|
+
if @head == nil
|
49
|
+
@head = node
|
50
|
+
elsif
|
51
|
+
node.prev = @tail
|
52
|
+
@tail.next = node
|
53
|
+
end
|
54
|
+
@tail = node
|
55
|
+
end
|
56
|
+
|
57
|
+
# Extrae el último elemento de la lista
|
58
|
+
def extract_end
|
59
|
+
nodo = @tail
|
60
|
+
|
61
|
+
if nodo != nil
|
62
|
+
if nodo.prev != nil
|
63
|
+
@tail = nodo.prev
|
64
|
+
@tail.next = nil
|
65
|
+
else
|
66
|
+
@head = nil
|
67
|
+
@tail = nil
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
nodo
|
72
|
+
end
|
73
|
+
|
74
|
+
# Itera en la lista
|
75
|
+
def each
|
76
|
+
i = @head;
|
77
|
+
while i != nil
|
78
|
+
yield i.value
|
79
|
+
i = i.next
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
data/lib/dieta.rb
ADDED
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dieta_alu0100618426
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Airam Navas
|
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.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: Clase menu para dietas recomendadas.
|
98
|
+
email:
|
99
|
+
- alu0100618426@ull.edu.es
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".coveralls.yml"
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".travis.yml"
|
108
|
+
- CODE_OF_CONDUCT.md
|
109
|
+
- Gemfile
|
110
|
+
- Guardfile
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- bin/console
|
115
|
+
- bin/setup
|
116
|
+
- dieta.gemspec
|
117
|
+
- lib/dieta.rb
|
118
|
+
- lib/dieta/dieta_m.rb
|
119
|
+
- lib/dieta/lista.rb
|
120
|
+
- lib/dieta/version.rb
|
121
|
+
homepage: https://github.com/ULL-ESIT-LPP-1617/menu-dietetico-AiramNavas.git
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.6.8
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: Práctica 08
|
145
|
+
test_files: []
|