gem_diet_alu0100891782 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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="Practica6.html" title="Practica6 (module)">Practica6</a></span>
88
+
89
+
90
+
91
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Diet.html" title="Diet (class)">Diet</a></span>, <span class='object_link'><a href="Diet_Alim.html" title="Diet_Alim (class)">Diet_Alim</a></span>, <span class='object_link'><a href="Diet_edad.html" title="Diet_edad (class)">Diet_edad</a></span>, <span class='object_link'><a href="List.html" title="List (class)">List</a></span>, <span class='object_link'><a href="Node.html" title="Node (class)">Node</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 Tue Nov 22 19:30:50 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/practica6.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "dieta/version"
2
+ require "practica6/practica6"
3
+ require "practica6/practica7"
4
+ module Practica6
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,58 @@
1
+ class NewDiet
2
+ include Comparable
3
+ attr_reader :name, :titulo, :ingesta, :platos, :porcentajes, :vct
4
+ def initialize(name,&block)
5
+ @name=name
6
+ @ingesta = ""
7
+ @platos = []
8
+ @porcentajes = []
9
+ instance_eval(&block)
10
+ end
11
+
12
+ def <=>(other)
13
+ @porcentajes[0]<=>other.porcentajes[0]
14
+ end
15
+ def ==(other)
16
+ @ingesta==other.ingesta
17
+ @platos==other.platos
18
+ @porcentajes==other.porcentajes
19
+ @vct==other.vct
20
+ end
21
+
22
+ def titulo(title)
23
+ @titulo=title
24
+ end
25
+
26
+ def ingesta(options = {})
27
+
28
+ @ingesta << "(#{options[:min]} - #{options[:max]})" if options[:min] && options[:max]
29
+ end
30
+
31
+ def plato(options = {})
32
+ platos_tmp=""
33
+ platos_tmp << "- #{options[:descripcion]}, #{options[:porcion]}, #{options[:gramos]} gramos\n" if options[:descripcion] && options[:porcion] && options[:gramos]
34
+ @platos << platos_tmp
35
+ end
36
+ def porcentajes(options = {})
37
+ tmp=""
38
+ tmp << "#{options[:vct]}"
39
+ @porcentajes << tmp
40
+ tmp=""
41
+ tmp << "#{options[:proteinas]}% #{options[:grasas]}% #{options[:hidratos]}%" if options[:vct] && options[:proteinas] && options[:grasas] && options[:hidratos]
42
+ @porcentajes << tmp
43
+ #@vct=options[:vct] if options[:vct]
44
+ end
45
+ def to_s
46
+ s="#{@titulo} #{@ingesta}%\n"
47
+ $i=0
48
+ for i in 0..platos.length
49
+ s+="#{@platos[i]}"
50
+ $i=$i+1
51
+ end
52
+ s+="VCT #{@porcentajes[0]} | #{porcentajes[1]}"
53
+ s
54
+ end
55
+ end
56
+
57
+
58
+
@@ -0,0 +1,88 @@
1
+ require "version"
2
+ class Diet
3
+ include Comparable
4
+ attr_reader :title
5
+ attr_reader :percentage
6
+ attr_reader :des_plato
7
+ attr_reader :con_plato
8
+ attr_reader :data
9
+ attr_reader :vct
10
+ #inicializamos la clase con un titulo, un porcentaje, un conjunto de platos, un valor calorico y unos valores de proteinas, grasas...
11
+ def initialize(title,percentage,con_plato,vct,data)
12
+ @title=title
13
+ @percentage=percentage
14
+ @con_plato = Array.new + con_plato
15
+ @des_plato = con_plato[0]
16
+ @vct = vct
17
+ @data = Array.new + data
18
+ end
19
+ #operadores de <,<=,>,>=
20
+ def <=>(other)
21
+ vct<=>other.vct
22
+ end
23
+ #operador de ==: compara cada variables de instancia de la clase
24
+ def ==(other)
25
+ title==other.title
26
+ percentage==other.percentage
27
+ des_plato==other.des_plato
28
+ con_plato==other.con_plato
29
+ data==other.data
30
+ vct==other.vct
31
+ end
32
+ #metodo que devuelve el nombre del primer plato
33
+ def obtain_plate
34
+ con_plato[0][0]
35
+ end
36
+ #metodo que devuelve el titulo de la dieta
37
+ def menu_title
38
+ title
39
+ end
40
+ #metodo que devuelve el porcentaje que supone del dia entero
41
+ def daily_percentage
42
+ percentage
43
+ end
44
+ #metodo que devuelve el nombre de uno de los platos
45
+ def one_plate (num)
46
+ con_plato[num][0]
47
+
48
+ end
49
+ #metodo que devuelve el nombre del conjunto de platos
50
+ def group_plates
51
+ s = "#{con_plato[0][0]}"
52
+ $i=1
53
+ while $i < con_plato.length do
54
+ s+= ", "
55
+ s+= "#{con_plato[$i][0]}"
56
+ $i+=1
57
+ end
58
+ s
59
+ end
60
+ #metodo que devuelve el valor calorico
61
+ def valor
62
+ vct
63
+ end
64
+ #metodo que devuelve el porcentaje de proteinas
65
+ def prot
66
+ data[0]
67
+ end
68
+ #metodo que devuelve el porcentaje de grasas
69
+ def gras
70
+ data[1]
71
+ end
72
+ #metodo que devuelve el porcentaje de hodratos de carbono
73
+ def hid_car
74
+ data[2]
75
+ end
76
+ #metodo que imprime formateada la dieta completa
77
+ def to_s
78
+ s="#{title} (#{percentage}%)\n"
79
+ $i=0
80
+ while $i<con_plato.length do
81
+ s+= "- #{con_plato[$i][0]}, #{con_plato[$i][1]}, #{con_plato[$i][2]} gr\n"
82
+ $i+=1
83
+ end
84
+ s+="V.C.T | % #{vct} kcal | #{data[0]}% - #{data[1]} - #{data[2]}"
85
+
86
+ end
87
+
88
+ end
@@ -0,0 +1,90 @@
1
+ Node = Struct.new(:value,:next,:prev)
2
+ class List
3
+ include Enumerable
4
+ attr_reader :head,:tail
5
+ #inicializamos la lista doblemente enlazada con un head y un tail
6
+ def initialize()
7
+ @head=Node.new()
8
+ @tail=@head
9
+
10
+ end
11
+ #metodo each que recorre cada nodo del vector para poder usar funciones de Enumerable
12
+ def each
13
+ aux=@head
14
+ while aux.next!=nil
15
+ yield aux.value
16
+ aux=aux.next
17
+ end
18
+ end
19
+ #metodo que extrae el primer elemento de la lista
20
+ def get_first
21
+ other=@head
22
+ @head=@head.next
23
+ other.value
24
+ end
25
+ #metodo que inserta un elemento al principio de la lista
26
+ def add(other)
27
+ nuevo=Node.new(other,nil,nil)
28
+ if(@head==nil)
29
+ @head=nuevo
30
+ @head.next=nil
31
+ @head.prev=nil
32
+ @tail=@head
33
+
34
+ else
35
+ nuevo.next=@head
36
+ @head.prev=nuevo
37
+ @head=nuevo
38
+
39
+ end
40
+ end
41
+ #metodo que añade varios elementos al principio de la lista
42
+ def add_mult(other)
43
+ for i in 0..other.length-1
44
+ add(other[i])
45
+ end
46
+ end
47
+ #metodo que inserta un elemento al final de la lista
48
+ def add_end(other)
49
+ nuevo=Node.new(other,nil,nil)
50
+ if(@head==@tail)
51
+ if(@head==nil)
52
+ @tail=nuevo
53
+ @head=@tail
54
+ else
55
+ @tail.next=nuevo
56
+ nuevo.prev=@tail
57
+ @tail=nuevo
58
+ @head.next=@tail
59
+ end
60
+ else
61
+ @tail.next=nuevo
62
+ nuevo.prev=@tail
63
+ @tail=nuevo
64
+ end
65
+ end
66
+ #metodo que extrae el ultimo elemento de la lista
67
+ def get_last
68
+ result=""
69
+ if(@head==@tail)
70
+ if(@head==nil)
71
+ result=nil
72
+ else
73
+ result=@tail.value
74
+ @tail=nil
75
+ @head=nil
76
+ end
77
+ else
78
+ result=@tail.value
79
+ @tail=@tail.prev
80
+ @tail.next=nil
81
+ end
82
+ result
83
+ end
84
+ #metodo que inserta varios elementos al final de la lista
85
+ def add_end_mult(other)
86
+ for i in 0..other.length-1
87
+ add_end(other[i])
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,45 @@
1
+ require "practica6"
2
+
3
+ class Diet_Alim < Diet
4
+ #clase hija de la clase dieta
5
+ attr_reader :alimentos
6
+ #inicializamos la clase hija con las variables de instancia de la clase padre y sumamos la variable alimentos
7
+ def initialize(title,percentage,con_plato,vct,data,alimentos)
8
+ super(title,percentage,con_plato,vct,data)
9
+ @alimentos=alimentos
10
+ end
11
+ #metodo que imprime la dieta formateada
12
+ def to_s
13
+ s=""
14
+ s << super.to_s
15
+ s << "\nAlimentos: #{@alimentos}"
16
+ s
17
+ end
18
+ #metodo que devuelve el conjunto de alimentos de grupo
19
+ def get_group
20
+ s="#{@alimentos}"
21
+ s
22
+ end
23
+
24
+ end
25
+
26
+ class Diet_edad < Diet
27
+ #clase hija de dieta que añade el grupo por edades
28
+ attr_reader :edades
29
+ def initialize(title,percentage,con_plato,vct,data,edades)
30
+ super(title,percentage,con_plato,vct,data)
31
+ @edades=edades
32
+ end
33
+ #metodo que imprime la dieta formateada
34
+ def to_s
35
+ s=""
36
+ s << super.to_s
37
+ s << "\nEdades: #{@edades}"
38
+ s
39
+ end
40
+ #metodo que devuelve el grupo por edades de la dieta
41
+ def get_group
42
+ s="#{@edades}"
43
+ s
44
+ end
45
+ end
@@ -0,0 +1,3 @@
1
+ module Practica6
2
+ VERSION = "0.1.0"
3
+ end
data/practica6.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 'practica6/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gem_diet_alu0100891782"
8
+ spec.version = Practica6::VERSION
9
+ spec.authors = ["Tarun"]
10
+ spec.email = ["alu0100891782@ull.edu.es"]
11
+
12
+ spec.summary = %q{this structures of files contains a list of diet class.}
13
+ spec.description = %q{the diet class is conformed by a title, some plates and other values such as fats, proteins and calories. The list contains some diets one next to other.}
14
+ spec.homepage = "https://github.com/ULL-ESIT-LPP-1617/menu-dietetico-alu0100891782.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
+ # 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
+
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
+
40
+
41
+ end