pract07 0.1.0

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.
@@ -0,0 +1,114 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Top Level Namespace
8
+
9
+ &mdash; Documentation by YARD 0.9.5
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+
41
+
42
+ <span class="title">Top Level Namespace</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <iframe id="search_frame" src="class_list.html"></iframe>
63
+
64
+ <div id="content"><h1>Top Level Namespace
65
+
66
+
67
+
68
+ </h1>
69
+ <div class="box_info">
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ </div>
82
+
83
+ <h2>Defined Under Namespace</h2>
84
+ <p class="children">
85
+
86
+
87
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Pract07.html" title="Pract07 (module)">Pract07</a></span>
88
+
89
+
90
+
91
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Dieta.html" title="Dieta (class)">Dieta</a></span>, <span class='object_link'><a href="Edad.html" title="Edad (class)">Edad</a></span>, <span class='object_link'><a href="Food.html" title="Food (class)">Food</a></span>, <span class='object_link'><a href="List.html" title="List (class)">List</a></span>
92
+
93
+
94
+ </p>
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+ </div>
105
+
106
+ <div id="footer">
107
+ Generated on Wed Nov 23 12:53:02 2016 by
108
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
109
+ 0.9.5 (ruby-2.3.0).
110
+ </div>
111
+
112
+ </div>
113
+ </body>
114
+ </html>
data/lib/pract07.rb ADDED
@@ -0,0 +1,13 @@
1
+ #require "pract06/version"
2
+ #require "pract06/micodigo.rb"
3
+
4
+ module Pract07
5
+ # Your code goes here...
6
+
7
+ #se deja como esta
8
+ end
9
+
10
+ #if __FILE__ == $0
11
+ # a = Dieta.new("ALMUERZO",[30,35],["Bueno","Bonito","Barato"],["Rico","Genial"],[65, 70, 6],750,[20,3,2])
12
+ # puts a.to_s
13
+ #end
@@ -0,0 +1,193 @@
1
+ class Dieta # Clase que contiene un menú
2
+ include Comparable
3
+ attr_accessor :tipo_dieta, :ingesta2, :descripcion, :racion, :cantidad, :kcal, :proteinas, :grasas, :hidratos
4
+ def initialize(&block)
5
+ self.tipo_dieta = [] #Tipo de menu: almuerzo, desayuno...
6
+ self.ingesta2 = []
7
+ self.descripcion = [] #descripcion del menu
8
+ self.racion = [] #array de arrays que contienen la porcion de comida que lleva cada plato
9
+ self.cantidad = [] #cantidad generalmente en gramos de comida
10
+ self.kcal = [] # V.C.T del menu
11
+ self.proteinas = [] #array de porcentajes que muestran: proteinas, grasas e hidratos por menu
12
+ self.grasas = []
13
+ self.hidratos = []
14
+ if block_given?
15
+ if block.arity == 1
16
+ yield self
17
+ else
18
+ instance_eval(&block)
19
+ end
20
+ end
21
+ end
22
+
23
+ def titulo(text)
24
+ self.tipo_dieta = text
25
+ end
26
+
27
+ def plato(options = {})
28
+ descripcion << "#{options[:descripcion]}" if options[:descripcion]
29
+ racion << "#{options[:porcion]}" if options[:porcion]
30
+ cantidad << "#{options[:gramos]}" if options[:gramos]
31
+ end
32
+
33
+ def ingesta(text, options = {})
34
+ ingesta = text
35
+ ingesta << "#{options[:min]}" if options[:min]
36
+ ingesta << "#{options[:max]}" if options[:max]
37
+ ingesta2 << ingesta
38
+ end
39
+
40
+ def porcentajes(options = {})
41
+ kcal << "#{options[:vct]}" if options[:vct]
42
+ proteinas << "#{options[:proteinas]}" if options[:proteinas]
43
+ grasas << "#{options[:grasas]}" if options[:grasas]
44
+ hidratos << "#{options[:hidratos]}" if options[:hidratos]
45
+ end
46
+
47
+ def get_platos #devuelve todos los platos que hay con sus descripciones
48
+ i=0
49
+ s= ""
50
+ while (descripcion[i] != nil && cantidad[i] != nil) do
51
+ s += "- #{descripcion[i]}, "
52
+ if (racion[i] != nil)
53
+ s += "#{racion[i]}, "
54
+ end
55
+ s += "#{cantidad[i]} g"
56
+ s += "\n"
57
+ i += 1
58
+ end
59
+ s #se devuelve e imprime
60
+ end
61
+
62
+ def get_titulo #devuelve el tipo de comida mas su ingesta diaria
63
+ s = "#{tipo_dieta} "
64
+ if (ingesta2[1] == nil)
65
+ s += "(#{ingesta2[0]}%)"
66
+ else
67
+ s += "(#{ingesta2[0]}% - #{ingesta2[1]}%)"
68
+ end
69
+ s #se devuelve e imprime
70
+ end
71
+
72
+ def get_descripcion(pos) #devuelve el nombre del plato especificado en "pos"
73
+ s = "#{descripcion[pos]}"
74
+ s #se devuelve e imprime
75
+ end
76
+
77
+ def get_to_(pos) #devuelve una linea con la descripcion completa de un plato
78
+ s = "- #{descripcion[pos]}, "
79
+ if (racion[pos] != nil)
80
+ s += "#{racion[pos]}, "
81
+ end
82
+ s += "#{cantidad[pos]} g"
83
+ s #se devuelve e imprime
84
+ end
85
+
86
+ def to_s #devuelve la salida con todos los datos
87
+ s = "#{tipo_dieta} "
88
+ if (ingesta2[1] == nil)
89
+ s += "(#{ingesta2[0]}%)"
90
+ else
91
+ s += "(#{ingesta2[0]}% - #{ingesta2[1]}%)"
92
+ end
93
+ s += "\n"
94
+ i = 0
95
+ while (descripcion[i] != nil && cantidad[i] != nil) do
96
+ s += "- #{descripcion[i]}, "
97
+ if (racion[i] != nil)
98
+ s += "#{racion[i]}, "
99
+ end
100
+ s += "#{cantidad[i]} g"
101
+ s += "\n"
102
+ i += 1
103
+ end
104
+ s += "V.C.T. | %"
105
+ s += "\t"
106
+ s += "#{kcal[0]} kcal |"
107
+ if (proteinas != nil)
108
+ s += " #{proteinas[0]}%"
109
+ s += " -"
110
+ end
111
+ if (grasas != nil)
112
+ s += " #{grasas[0]}%"
113
+ s += " -"
114
+ end
115
+ if (hidratos != nil)
116
+ s += " #{hidratos[0]}%"
117
+ end
118
+ s #se devuelve e imprime
119
+ end
120
+
121
+ #Comparacion
122
+
123
+ def <=>(other)
124
+ kcal <=> other.kcal
125
+ end
126
+
127
+ def ==(other)
128
+ if kcal == other.kcal && percent == other.percent
129
+ return true
130
+ else
131
+ return false
132
+ end
133
+ end
134
+
135
+ end
136
+
137
+ class Food < Dieta # Clase hija de dieta, añade tipo de comida
138
+
139
+ def tip(verduras, leche, cereales, frutas) #añade el tipo que comida que se encuentra en el menú
140
+ @verduras = verduras #muestra si el plato contiene verduras y hortalizas
141
+ @leche = leche #muestra si el plato contiene leche, huevos, pescado, carne y frutos secos
142
+ @cereales = cereales #muestra si el plato contiene cereales,legumbres y féculas
143
+ @frutas = frutas #muestra si el plato contiene frutas
144
+ end
145
+
146
+ def to_s #devuelve la salida con todos los datos
147
+ s = super
148
+ s += "\n"
149
+ s += "Contiene: "
150
+ if (@verduras != nil && @verduras != 0)
151
+ s += "Verduras, "
152
+ end
153
+ if (@leche != nil && @leche != 0)
154
+ s += "Leche, "
155
+ end
156
+ if (@cereales != nil && @cereales != 0)
157
+ s += "Cereales, "
158
+ end
159
+ if (@frutas != nil && @frutas != 0)
160
+ s += "Frutas."
161
+ end
162
+ s
163
+ end
164
+ end
165
+
166
+ class Edad < Dieta # Clase hija de dieta, añade edad recomendada
167
+
168
+ def tip(a8, a13, a18) #añade el rango de edades adecuado para el menú
169
+ @a8 = a8 #de 4 a 8 años
170
+ @a13 = a13 #de 9 a 13 años
171
+ @a18 = a18 #de 14 a 18 años
172
+ end
173
+
174
+ def to_s #devuelve la salida con todos los datos
175
+ s = super
176
+ s += "\n"
177
+ s += "Dirigido a personas de: "
178
+ if (@a8 != nil && @a8 != 0)
179
+ s += "4 a 8, "
180
+ end
181
+ if (@a13 != nil && @a13 != 0)
182
+ s += "9 a 13, "
183
+ end
184
+ if (@a18 != nil && @a18 != 0)
185
+ s += "14 a 18 "
186
+ end
187
+ s += "años."
188
+ s
189
+ end
190
+ end
191
+
192
+
193
+
@@ -0,0 +1,61 @@
1
+ class List # Clase que implementa una lista
2
+ include Enumerable
3
+ attr_accessor :top, :end, :tam
4
+
5
+ def initialize
6
+ @top = nil #cabeza de la lista
7
+ @end = nil #cola de la lista
8
+ @tam = nil #tamaño de la lista
9
+ end
10
+
11
+ def pushtop(entry) #introducir nodo por la cabeza de la lista
12
+ if @top.nil?
13
+ @top = entry
14
+ @end = entry
15
+ @tam = 1
16
+ else
17
+ entry.next = @top
18
+ @top = entry
19
+ @tam += 1
20
+ end
21
+ end
22
+
23
+ def pushend(entry) #introducir nodo por la cola de la lista
24
+ if @top.nil?
25
+ @top = entry
26
+ @end = entry
27
+ @tam = 1
28
+ else
29
+ @end.next = entry
30
+ @end = entry
31
+ @tam += 1
32
+ end
33
+ end
34
+
35
+ def pop #sacar el nodo que se encuentre en la cabeza de la lista
36
+ return nil if @top.nil?
37
+ entry = @top
38
+ @top = @top.next
39
+ @tam -= 1
40
+ return entry
41
+ end
42
+
43
+ #Función para ir sacando el valor de los nodos y compararlos con las funciones Enumerable
44
+
45
+ def each
46
+ if @top.nil?
47
+ return nil
48
+ end
49
+ entry = @top
50
+ until entry.nil?
51
+ yield entry.value
52
+ entry = entry.next
53
+ end
54
+ end
55
+
56
+ def <=>(other)
57
+ tam <=> other.tam
58
+ end
59
+
60
+
61
+ end
@@ -0,0 +1,3 @@
1
+ module Pract07
2
+ VERSION = "0.1.0"
3
+ end
data/pract07.gemspec ADDED
@@ -0,0 +1,42 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pract07/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pract07"
8
+ spec.version = Pract07::VERSION
9
+ spec.authors = ["Daniel Jimenez"]
10
+ spec.email = ["alu0100826555@ull.edu.es"]
11
+
12
+ spec.summary = %q{Practica 7, clases de ruby}
13
+ spec.description = %q{Implementacion de una lista de listas para almacenar menus dietéticos.}
14
+ spec.homepage = "https://github.com/ULL-ESIT-LPP-1617/tdd-menu-lpp-26.git"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ #if spec.respond_to?(:metadata)
19
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
+ #else
21
+ # raise "RubyGems 2.0 or newer is required to protect against " \
22
+ # "public gem pushes."
23
+ #end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+ spec.metadata["yard.run"] = "yri"
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
+ spec.add_development_dependency "yard"
40
+ spec.add_development_dependency "sinatra"
41
+
42
+ end
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pract07
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Jimenez
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
+ - !ruby/object:Gem::Dependency
98
+ name: yard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sinatra
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Implementacion de una lista de listas para almacenar menus dietéticos.
126
+ email:
127
+ - alu0100826555@ull.edu.es
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - Gemfile
133
+ - Gemfile.lock
134
+ - Guardfile
135
+ - README.md
136
+ - Rakefile
137
+ - bin/console
138
+ - bin/setup
139
+ - doc/Dieta.html
140
+ - doc/Edad.html
141
+ - doc/Food.html
142
+ - doc/List.html
143
+ - doc/Pract07.html
144
+ - doc/_index.html
145
+ - doc/class_list.html
146
+ - doc/css/common.css
147
+ - doc/css/full_list.css
148
+ - doc/css/style.css
149
+ - doc/file.README.html
150
+ - doc/file_list.html
151
+ - doc/frames.html
152
+ - doc/index.html
153
+ - doc/js/app.js
154
+ - doc/js/full_list.js
155
+ - doc/js/jquery.js
156
+ - doc/method_list.html
157
+ - doc/top-level-namespace.html
158
+ - lib/pract07.rb
159
+ - lib/pract07/Dieta.rb
160
+ - lib/pract07/List.rb
161
+ - lib/pract07/version.rb
162
+ - pract07.gemspec
163
+ homepage: https://github.com/ULL-ESIT-LPP-1617/tdd-menu-lpp-26.git
164
+ licenses: []
165
+ metadata:
166
+ yard.run: yri
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubyforge_project:
183
+ rubygems_version: 2.5.1
184
+ signing_key:
185
+ specification_version: 4
186
+ summary: Practica 7, clases de ruby
187
+ test_files: []