MenuDietetico_alu0100825510 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +4 -0
  7. data/Guardfile +82 -0
  8. data/LICENSE.txt +21 -0
  9. data/MenuDietetico.gemspec +34 -0
  10. data/README.md +41 -0
  11. data/Rakefile +6 -0
  12. data/bin/console +14 -0
  13. data/bin/setup +8 -0
  14. data/doc/CODE_OF_CONDUCT_md.html +195 -0
  15. data/doc/Gemfile.html +100 -0
  16. data/doc/Gemfile_lock.html +182 -0
  17. data/doc/Guardfile.html +180 -0
  18. data/doc/LICENSE_txt.html +117 -0
  19. data/doc/List.html +532 -0
  20. data/doc/Menu.html +645 -0
  21. data/doc/MenuAlimentos.html +231 -0
  22. data/doc/MenuDietetico.html +109 -0
  23. data/doc/MenuDietetico_gemspec.html +135 -0
  24. data/doc/MenuEdad.html +231 -0
  25. data/doc/Object.html +116 -0
  26. data/doc/Plato.html +247 -0
  27. data/doc/README_md.html +164 -0
  28. data/doc/Rakefile.html +101 -0
  29. data/doc/bin/setup.html +101 -0
  30. data/doc/created.rid +19 -0
  31. data/doc/css/fonts.css +167 -0
  32. data/doc/css/rdoc.css +590 -0
  33. data/doc/fonts/Lato-Light.ttf +0 -0
  34. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  35. data/doc/fonts/Lato-Regular.ttf +0 -0
  36. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  37. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  38. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  39. data/doc/images/add.png +0 -0
  40. data/doc/images/arrow_up.png +0 -0
  41. data/doc/images/brick.png +0 -0
  42. data/doc/images/brick_link.png +0 -0
  43. data/doc/images/bug.png +0 -0
  44. data/doc/images/bullet_black.png +0 -0
  45. data/doc/images/bullet_toggle_minus.png +0 -0
  46. data/doc/images/bullet_toggle_plus.png +0 -0
  47. data/doc/images/date.png +0 -0
  48. data/doc/images/delete.png +0 -0
  49. data/doc/images/find.png +0 -0
  50. data/doc/images/loadingAnimation.gif +0 -0
  51. data/doc/images/macFFBgHack.png +0 -0
  52. data/doc/images/package.png +0 -0
  53. data/doc/images/page_green.png +0 -0
  54. data/doc/images/page_white_text.png +0 -0
  55. data/doc/images/page_white_width.png +0 -0
  56. data/doc/images/plugin.png +0 -0
  57. data/doc/images/ruby.png +0 -0
  58. data/doc/images/tag_blue.png +0 -0
  59. data/doc/images/tag_green.png +0 -0
  60. data/doc/images/transparent.png +0 -0
  61. data/doc/images/wrench.png +0 -0
  62. data/doc/images/wrench_orange.png +0 -0
  63. data/doc/images/zoom.png +0 -0
  64. data/doc/index.html +117 -0
  65. data/doc/js/darkfish.js +161 -0
  66. data/doc/js/jquery.js +5 -0
  67. data/doc/js/navigation.js +142 -0
  68. data/doc/js/navigation.js.gz +0 -0
  69. data/doc/js/search.js +109 -0
  70. data/doc/js/search_index.js +1 -0
  71. data/doc/js/search_index.js.gz +0 -0
  72. data/doc/js/searcher.js +228 -0
  73. data/doc/js/searcher.js.gz +0 -0
  74. data/doc/table_of_contents.html +237 -0
  75. data/lib/MenuDietetico.rb +7 -0
  76. data/lib/MenuDietetico/lista.rb +139 -0
  77. data/lib/MenuDietetico/menu.rb +145 -0
  78. data/lib/MenuDietetico/menu_dsl.rb +85 -0
  79. data/lib/MenuDietetico/version.rb +3 -0
  80. metadata +206 -0
@@ -0,0 +1,7 @@
1
+ require "MenuDietetico/version"
2
+ require "MenuDietetico/menu"
3
+ require "MenuDietetico/lista"
4
+ require "MenuDietetico/menu_dsl"
5
+ module MenuDietetico
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,139 @@
1
+ Node = Struct.new(:value, :next, :prev)
2
+
3
+
4
+ class List
5
+
6
+ include Enumerable
7
+
8
+ attr_accessor :inicio, :final
9
+
10
+
11
+
12
+ def extract_beginning
13
+
14
+ aux = @inicio
15
+ @inicio = @inicio.next
16
+ if(@inicio != nil)then
17
+ @inicio.prev = nil
18
+ end
19
+
20
+ if(@inicio == nil)then
21
+ @final = nil
22
+ end
23
+
24
+ return aux.value
25
+
26
+ end
27
+
28
+ def extract_end
29
+
30
+ aux = @final
31
+ @final = @final.prev
32
+
33
+ if(@final != nil)then
34
+ @final.next = nil
35
+ end
36
+
37
+ if(@final == nil)then
38
+ @inicio = nil
39
+ end
40
+
41
+ return aux.value
42
+
43
+ end
44
+
45
+ def insert_beginning(value)
46
+
47
+ if(@inicio == nil) then
48
+ @inicio = Node.new(value, nil, nil)
49
+ @final = @inicio
50
+
51
+ else
52
+ aux = Node.new(value,@inicio,nil)
53
+ @inicio.prev = aux
54
+ @inicio = aux
55
+
56
+ end
57
+
58
+ return true
59
+
60
+ end
61
+
62
+ def insert_end(value)
63
+
64
+ if(@final == nil) then
65
+ @final = Node.new(value, nil, nil)
66
+ @inicio = @final
67
+
68
+ else
69
+ aux = Node.new(value,nil,@final)
70
+ @final.next = aux
71
+ @final = aux
72
+
73
+ end
74
+
75
+ return true
76
+
77
+
78
+ end
79
+
80
+
81
+
82
+
83
+
84
+
85
+ def empty
86
+
87
+ if(@inicio == nil) then
88
+ return true
89
+ else return false
90
+ end
91
+
92
+ end
93
+
94
+ def to_s
95
+
96
+ string=[]
97
+ aux = @inicio
98
+ i=0
99
+
100
+ while(aux.next != nil) do
101
+ string[i]=aux.value.to_s
102
+ aux = aux.next
103
+ i += 1
104
+ end
105
+ string[i] = aux.value.to_s
106
+
107
+ return string
108
+ end
109
+
110
+
111
+ #Al metodo each se le puede pasar un bloque de codigo
112
+ # y ese bloque se va a colocar en cada campo yield y se ejecutará con los parámetros qe están al lado del yield
113
+ def each
114
+ return nil if @inicio.nil?
115
+ aux = @inicio #Creamos un nodo auxiliar
116
+ until aux.nil? #Y hasta que el nodo no sea nulo
117
+ yield aux[:value]
118
+ aux = aux.next
119
+ end
120
+ end
121
+
122
+ def [] (index)
123
+ case index
124
+ when 0
125
+ @inicio
126
+ when -1
127
+ @final
128
+ when :inicio,"inicio"
129
+ @inicio
130
+ when :final, "final"
131
+ @final
132
+ else
133
+ nil
134
+ end
135
+
136
+ end
137
+
138
+
139
+ end
@@ -0,0 +1,145 @@
1
+
2
+ class Plato
3
+
4
+ attr_reader :titulo, :porcion, :gramos
5
+
6
+ def initialize(titulo, porcion, gramos)
7
+
8
+ @titulo = titulo
9
+ @porcion = porcion
10
+ @gramos = gramos
11
+
12
+ end
13
+
14
+
15
+ def to_s
16
+ "#{@titulo}, #{@porcion}, #{@gramos}"
17
+ end
18
+
19
+ end
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+ class Menu
28
+
29
+ include Comparable
30
+
31
+ attr_reader :titulo, :porcentaje, :platos, :vct, :proteinas, :grasas, :hidratos_carbono
32
+
33
+ def initialize(titulo, porcentaje, platos, vct, proteinas, grasas, hidratos_carbono)
34
+
35
+ @titulo = titulo
36
+ @porcentaje = porcentaje
37
+ @platos = platos
38
+ @vct = vct
39
+ @proteinas = proteinas
40
+ @grasas = grasas
41
+ @hidratos_carbono = hidratos_carbono
42
+
43
+ end
44
+
45
+
46
+ def to_s
47
+
48
+ string = "#{@titulo} (#{@porcentaje}) \n"
49
+
50
+ for i in (0..@platos.length-1)
51
+ string += "- #{@platos[i]} \n"
52
+ end
53
+
54
+ string += "V.C.T | % #{@vct} kcal | #{@proteinas} - #{@grasas} - #{@hidratos_carbono}"
55
+
56
+ string
57
+
58
+
59
+ end
60
+
61
+
62
+ def get_titulo
63
+ @titulo.to_s
64
+ end
65
+
66
+ def get_porcentaje
67
+ @porcentaje.to_s
68
+ end
69
+
70
+ def get_platos
71
+ string=@platos[0].to_s
72
+ for i in (1..@platos.length-1)
73
+ string += @platos[i].to_s
74
+ end
75
+ string
76
+ end
77
+
78
+ def get_plato(n_plato)
79
+ platos[n_plato].to_s
80
+ end
81
+
82
+ def get_vct
83
+ @vct.to_s+" kcal"
84
+ end
85
+
86
+ def get_proteinas
87
+ @proteinas.to_s+"%"
88
+ end
89
+
90
+ def get_grasas
91
+ @grasas.to_s+"%"
92
+ end
93
+
94
+ def get_hidratos
95
+ @hidratos_carbono.to_s+"%"
96
+ end
97
+
98
+ def <=>(other) #Compara dos objetos de la misma jerarquía basandose en la variable calórica vct
99
+ return nil unless other.is_a? Menu
100
+ return @vct <=> other.vct
101
+ end
102
+
103
+
104
+ end
105
+
106
+
107
+ class MenuEdad < Menu
108
+
109
+ attr_reader :edad
110
+
111
+ def initialize(edad, menu)
112
+ super(menu.titulo,menu.porcentaje,menu.platos, menu.vct, menu.proteinas, menu.grasas, menu.hidratos_carbono)
113
+ @edad = edad
114
+
115
+
116
+ end
117
+
118
+ def to_s
119
+
120
+ title = super.to_s + "\nEdad:#{@edad}"
121
+ end
122
+
123
+
124
+ end
125
+
126
+ class MenuAlimentos < Menu
127
+
128
+ attr_reader :alimentos
129
+
130
+ def initialize(alimentos, menu)
131
+
132
+ super(menu.titulo,menu.porcentaje,menu.platos, menu.vct, menu.proteinas, menu.grasas, menu.hidratos_carbono)
133
+ @alimentos= alimentos
134
+
135
+ end
136
+
137
+ def to_s
138
+
139
+ title = super.to_s + "\nGrupo de alimentos:#{@alimentos}"
140
+ end
141
+
142
+
143
+
144
+
145
+ end
@@ -0,0 +1,85 @@
1
+
2
+ class Menu_dsl
3
+ include Comparable
4
+
5
+ attr_reader :etiqueta, :tit, :porcentaje, :platos, :vct, :proteinas, :grasas, :hidratos_carbono
6
+
7
+ def initialize (etiqueta, &block)
8
+ @porcentaje = {}
9
+ @platos = []
10
+ @etiqueta = etiqueta
11
+ instance_eval(&block)
12
+ end
13
+
14
+ def titulo(titulo)
15
+ @tit = titulo
16
+ end
17
+
18
+ def ingesta(ingest = {})
19
+ @porcentaje[:min] = ingest[:min]
20
+ @porcentaje[:max] = ingest[:max]
21
+ end
22
+
23
+ def plato(plat = {})
24
+ plato_auxiliar = Plato.new(plat[:descripcion], plat[:porcion], plat[:gramos])
25
+ platos << plato_auxiliar
26
+ end
27
+
28
+ def porcentajes(porcent = {})
29
+ @vct = porcent[:vct]
30
+ @grasas = porcent[:grasas]
31
+ @hidratos_carbono = porcent[:hidratos]
32
+ @proteinas = porcent[:proteinas]
33
+ end
34
+
35
+ def <=>(other) #Compara dos objetos de la misma jerarquía basandose en la variable calórica vct
36
+ return @vct <=> other.vct
37
+ end
38
+
39
+ def to_s
40
+
41
+ string = "#{@tit} (#{@porcentaje[:min]})"
42
+ if(@porcentaje[:max] != nil)then
43
+ string << " (#{@porcentaje[:max]}) \n"
44
+ else
45
+ string << "\n"
46
+ end
47
+
48
+ platos.each_with_index do |plato, index|
49
+ string << "- #{plato} \n"
50
+ end
51
+
52
+ string << "V.C.T | % #{@vct} kcal | #{@proteinas} - #{@grasas} - #{@hidratos_carbono}"
53
+
54
+ string
55
+ end
56
+
57
+
58
+ def get_plato(n_plato)
59
+ platos[n_plato].to_s
60
+ end
61
+
62
+ end
63
+
64
+
65
+
66
+
67
+ class MenuEdad_dsl < Menu_dsl
68
+ attr_accessor :edad
69
+
70
+ def initialize(edad, etiqueta, &block)
71
+ @edad = edad
72
+ super(etiqueta, &block)
73
+ end
74
+
75
+ end
76
+
77
+
78
+ class MenuAlimentos_dsl < Menu_dsl
79
+ attr_accessor :alimentos
80
+
81
+ def initialize(alimentos, etiqueta, &block)
82
+ @alimentos = alimentos
83
+ super(etiqueta, &block)
84
+ end
85
+ end
@@ -0,0 +1,3 @@
1
+ module MenuDietetico
2
+ VERSION = "0.1.4"
3
+ end
metadata ADDED
@@ -0,0 +1,206 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: MenuDietetico_alu0100825510
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ platform: ruby
6
+ authors:
7
+ - Alberto Ruiz
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-12-15 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: Gema para crear menús dietéticos
98
+ email:
99
+ - alu0100825510@ull.edu.es
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - CODE_OF_CONDUCT.md
108
+ - Gemfile
109
+ - Guardfile
110
+ - LICENSE.txt
111
+ - MenuDietetico.gemspec
112
+ - README.md
113
+ - Rakefile
114
+ - bin/console
115
+ - bin/setup
116
+ - doc/CODE_OF_CONDUCT_md.html
117
+ - doc/Gemfile.html
118
+ - doc/Gemfile_lock.html
119
+ - doc/Guardfile.html
120
+ - doc/LICENSE_txt.html
121
+ - doc/List.html
122
+ - doc/Menu.html
123
+ - doc/MenuAlimentos.html
124
+ - doc/MenuDietetico.html
125
+ - doc/MenuDietetico_gemspec.html
126
+ - doc/MenuEdad.html
127
+ - doc/Object.html
128
+ - doc/Plato.html
129
+ - doc/README_md.html
130
+ - doc/Rakefile.html
131
+ - doc/bin/setup.html
132
+ - doc/created.rid
133
+ - doc/css/fonts.css
134
+ - doc/css/rdoc.css
135
+ - doc/fonts/Lato-Light.ttf
136
+ - doc/fonts/Lato-LightItalic.ttf
137
+ - doc/fonts/Lato-Regular.ttf
138
+ - doc/fonts/Lato-RegularItalic.ttf
139
+ - doc/fonts/SourceCodePro-Bold.ttf
140
+ - doc/fonts/SourceCodePro-Regular.ttf
141
+ - doc/images/add.png
142
+ - doc/images/arrow_up.png
143
+ - doc/images/brick.png
144
+ - doc/images/brick_link.png
145
+ - doc/images/bug.png
146
+ - doc/images/bullet_black.png
147
+ - doc/images/bullet_toggle_minus.png
148
+ - doc/images/bullet_toggle_plus.png
149
+ - doc/images/date.png
150
+ - doc/images/delete.png
151
+ - doc/images/find.png
152
+ - doc/images/loadingAnimation.gif
153
+ - doc/images/macFFBgHack.png
154
+ - doc/images/package.png
155
+ - doc/images/page_green.png
156
+ - doc/images/page_white_text.png
157
+ - doc/images/page_white_width.png
158
+ - doc/images/plugin.png
159
+ - doc/images/ruby.png
160
+ - doc/images/tag_blue.png
161
+ - doc/images/tag_green.png
162
+ - doc/images/transparent.png
163
+ - doc/images/wrench.png
164
+ - doc/images/wrench_orange.png
165
+ - doc/images/zoom.png
166
+ - doc/index.html
167
+ - doc/js/darkfish.js
168
+ - doc/js/jquery.js
169
+ - doc/js/navigation.js
170
+ - doc/js/navigation.js.gz
171
+ - doc/js/search.js
172
+ - doc/js/search_index.js
173
+ - doc/js/search_index.js.gz
174
+ - doc/js/searcher.js
175
+ - doc/js/searcher.js.gz
176
+ - doc/table_of_contents.html
177
+ - lib/MenuDietetico.rb
178
+ - lib/MenuDietetico/lista.rb
179
+ - lib/MenuDietetico/menu.rb
180
+ - lib/MenuDietetico/menu_dsl.rb
181
+ - lib/MenuDietetico/version.rb
182
+ homepage: https://github.com/ULL-ESIT-LPP-1617/menu-dietetico-alu0100825510.git
183
+ licenses:
184
+ - MIT
185
+ metadata: {}
186
+ post_install_message:
187
+ rdoc_options: []
188
+ require_paths:
189
+ - lib
190
+ required_ruby_version: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ required_rubygems_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ requirements: []
201
+ rubyforge_project:
202
+ rubygems_version: 2.5.1
203
+ signing_key:
204
+ specification_version: 4
205
+ summary: PRACTIA 11
206
+ test_files: []