Alimento 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.
- checksums.yaml +7 -0
- data/.coveralls.yml +6 -0
- data/.gitignore +12 -0
- data/.rake_tasks~ +8 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Alimento.gemspec +39 -0
- data/Gemfile +6 -0
- data/Guardfile +82 -0
- data/README.md +35 -0
- data/Rakefile +78 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/Alimentos.html +1854 -0
- data/docs/ListaDoble.html +1236 -0
- data/docs/Nodo.html +398 -0
- data/docs/_index.html +133 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +492 -0
- data/docs/file.README.html +117 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +117 -0
- data/docs/js/app.js +248 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +299 -0
- data/docs/top-level-namespace.html +110 -0
- data/lib/Alimento/alimentos.rb +193 -0
- data/lib/Alimento/glucemico.rb +333 -0
- data/lib/Alimento/lista_doble.rb +155 -0
- data/lib/Alimento/ordenacion.rb +321 -0
- data/lib/Alimento/tipo_alimento.rb +29 -0
- data/lib/Alimento/version.rb +3 -0
- data/lib/Alimento.rb +13 -0
- metadata +177 -0
| @@ -0,0 +1,155 @@ | |
| 1 | 
            +
            Nodo = Struct.new(:value, :next_node, :prev_node)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # @author Miguel Parra Esquivel (miguelpe83)
         | 
| 4 | 
            +
            # @abstract
         | 
| 5 | 
            +
            # @since 0.6.0
         | 
| 6 | 
            +
             | 
| 7 | 
            +
             | 
| 8 | 
            +
            # @return [String] objeto convertidos con el formato string
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            class ListaDoble
         | 
| 11 | 
            +
                include Enumerable
         | 
| 12 | 
            +
                #Contructor de la clase Lista
         | 
| 13 | 
            +
                def initialize
         | 
| 14 | 
            +
                    @cabeza = nil
         | 
| 15 | 
            +
                    @cola = nil
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                #Recorre la lista para el uso del módulo enumerable
         | 
| 19 | 
            +
            # @return [String] objeto convertidos con el formato string del recorrido de los nodos
         | 
| 20 | 
            +
                def each
         | 
| 21 | 
            +
                    nodo_aux = @cabeza
         | 
| 22 | 
            +
                    while nodo_aux != nil
         | 
| 23 | 
            +
                        yield nodo_aux.value
         | 
| 24 | 
            +
                        nodo_aux = nodo_aux.next_node
         | 
| 25 | 
            +
                    end
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            #Devuelve el elemento inicial de la lista
         | 
| 29 | 
            +
            # @return [String] objeto convertidos con el formato string del nodo que quiere mostrar
         | 
| 30 | 
            +
                def get_inicio
         | 
| 31 | 
            +
                   return @cabeza
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                #Devuelve el elemento final de la linea
         | 
| 35 | 
            +
            # @return [String] objeto convertidos con el formato string del nodo que quiere mostrar
         | 
| 36 | 
            +
                def get_final
         | 
| 37 | 
            +
                   return @final
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                #Comprueba si la lista está vacía
         | 
| 41 | 
            +
                # def is_empty
         | 
| 42 | 
            +
                #     # @inicio == nil
         | 
| 43 | 
            +
                #     r = false
         | 
| 44 | 
            +
                #     if(@cabeza == nil)
         | 
| 45 | 
            +
                #         r = true
         | 
| 46 | 
            +
                #     elsif
         | 
| 47 | 
            +
                #         r = false
         | 
| 48 | 
            +
                #     end
         | 
| 49 | 
            +
                #     return r
         | 
| 50 | 
            +
                # end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                #Inserta un elemento por el inicio de la lista
         | 
| 53 | 
            +
            # @param elemento [String] nodo que quiere añadir
         | 
| 54 | 
            +
            # @return [String] objeto convertidos con el formato string del nodo que quiere añadir
         | 
| 55 | 
            +
                def insertar(elemento) #inserta por el inicio
         | 
| 56 | 
            +
                    nodo_aux = Nodo.new(elemento, nil, nil)
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                    #if(is_empty())
         | 
| 59 | 
            +
             | 
| 60 | 
            +
             | 
| 61 | 
            +
                    if (@cabeza == nil && @cola == nil)
         | 
| 62 | 
            +
                        @cabeza = nodo_aux
         | 
| 63 | 
            +
                        @final = nodo_aux
         | 
| 64 | 
            +
                        @cabeza.next_node = nil
         | 
| 65 | 
            +
                        @cabeza.prev_node = nil
         | 
| 66 | 
            +
                        #@final = @inicio
         | 
| 67 | 
            +
                    elsif
         | 
| 68 | 
            +
                        aux = @cabeza
         | 
| 69 | 
            +
                        @cabeza = nodo_aux
         | 
| 70 | 
            +
                        @cabeza.next_node = aux
         | 
| 71 | 
            +
                        @cabeza.prev_node = nil
         | 
| 72 | 
            +
                        aux.prev_node = @cabeza
         | 
| 73 | 
            +
                    end
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                #Inserta un elemento por el final de la lista
         | 
| 77 | 
            +
            # @param elemento [String] nodo que quieres añadir a la cola
         | 
| 78 | 
            +
            # @return [String] objeto convertidos con el formato string del nodo añadido
         | 
| 79 | 
            +
                def insertar_final(elemento)
         | 
| 80 | 
            +
                    nodo_aux = Node.new(elemento, nil, nil)
         | 
| 81 | 
            +
                    if(is_empty())
         | 
| 82 | 
            +
                        @cabeza = nodo_aux
         | 
| 83 | 
            +
                        @final = nodo_aux
         | 
| 84 | 
            +
                        @cabeza.next_node = nil
         | 
| 85 | 
            +
                        @cabeza.prev_node = nil
         | 
| 86 | 
            +
                        @final.prev_node = nil
         | 
| 87 | 
            +
                        @final.next_node = nil
         | 
| 88 | 
            +
                        #@final = @inicio
         | 
| 89 | 
            +
                    elsif
         | 
| 90 | 
            +
                        aux = @final
         | 
| 91 | 
            +
                        @final = nodo_aux
         | 
| 92 | 
            +
                        @final.prev_node = aux
         | 
| 93 | 
            +
                        @final.next_node = nil
         | 
| 94 | 
            +
                    end
         | 
| 95 | 
            +
                end
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                #Inserta varios elementos por el inicio de la lista
         | 
| 98 | 
            +
            # @param vector [String] insertar muchos nodos y llama a insertar un nodo
         | 
| 99 | 
            +
            # @return [String] objeto convertidos con el formato string de los nodos añadidos
         | 
| 100 | 
            +
            def insertar_muchos(vector) #inserta muchos por el inicio
         | 
| 101 | 
            +
                i=0
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                while i<vector.length
         | 
| 104 | 
            +
                    self.insertar(vector[i])
         | 
| 105 | 
            +
                    i=i+1
         | 
| 106 | 
            +
                end
         | 
| 107 | 
            +
            end
         | 
| 108 | 
            +
             | 
| 109 | 
            +
            #Inserta varios elementos por el final de la lista
         | 
| 110 | 
            +
            #Se le pasa como argumento un vector con los elementos a insertar en la lista
         | 
| 111 | 
            +
            # @param vector [String] insertar muchos nodos y llama a insertar un nodo
         | 
| 112 | 
            +
            # @return [String] objeto convertidos con el formato string de los nodos añadidos
         | 
| 113 | 
            +
                def insertar_muchos_final(vector)
         | 
| 114 | 
            +
                    i=0
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                    while i<vector.length
         | 
| 117 | 
            +
                        self.insertar_final(vector[i])
         | 
| 118 | 
            +
                        i=i+1
         | 
| 119 | 
            +
                    end
         | 
| 120 | 
            +
                end
         | 
| 121 | 
            +
             | 
| 122 | 
            +
                #Extrae el inicio de la lista
         | 
| 123 | 
            +
            # @return [String] objeto convertidos con el formato string del nodo eliminado
         | 
| 124 | 
            +
                def extraer
         | 
| 125 | 
            +
                    if(is_empty())
         | 
| 126 | 
            +
                        return nil
         | 
| 127 | 
            +
                    elsif
         | 
| 128 | 
            +
                        node_aux = @inicio
         | 
| 129 | 
            +
                        @inicio = @inicio.next_node
         | 
| 130 | 
            +
                        node_aux.next_node = nil
         | 
| 131 | 
            +
                        node_aux.prev_node = nil
         | 
| 132 | 
            +
                        return node_aux.value
         | 
| 133 | 
            +
                    end
         | 
| 134 | 
            +
                end
         | 
| 135 | 
            +
             | 
| 136 | 
            +
                #Extrae un elemento del final de la lista
         | 
| 137 | 
            +
                # def extraer_final
         | 
| 138 | 
            +
                #     if(is_empty())
         | 
| 139 | 
            +
                #         return nil
         | 
| 140 | 
            +
                #     elsif
         | 
| 141 | 
            +
                #         node_aux = @final
         | 
| 142 | 
            +
                #         @final = @final.prev_node
         | 
| 143 | 
            +
                #         if(@final!=nil)
         | 
| 144 | 
            +
                #             @final.next_node=nil
         | 
| 145 | 
            +
                #         elsif
         | 
| 146 | 
            +
                #             @cabeza=nil
         | 
| 147 | 
            +
                #         end
         | 
| 148 | 
            +
                #         return node_aux.value
         | 
| 149 | 
            +
                #     end
         | 
| 150 | 
            +
                # end
         | 
| 151 | 
            +
            # @attr_reader [Symbol] describe los getter de la clase
         | 
| 152 | 
            +
            # @attr_writer [Symbol] describe los setter de la clase
         | 
| 153 | 
            +
                attr_accessor :cabeza
         | 
| 154 | 
            +
                attr_accessor :cola
         | 
| 155 | 
            +
            end
         | 
| @@ -0,0 +1,321 @@ | |
| 1 | 
            +
            require "Alimento/alimentos.rb"
         | 
| 2 | 
            +
            require 'benchmark'
         | 
| 3 | 
            +
            include Benchmark
         | 
| 4 | 
            +
             | 
| 5 | 
            +
             | 
| 6 | 
            +
            class Array
         | 
| 7 | 
            +
              NUM_ALIMENTOS = 5
         | 
| 8 | 
            +
              def burbuja_for (array)
         | 
| 9 | 
            +
                 #n=a.length
         | 
| 10 | 
            +
                 a = Array.new
         | 
| 11 | 
            +
                 a = array
         | 
| 12 | 
            +
                 for i in 0...a.length-1
         | 
| 13 | 
            +
                  for j in 0...a.length-i-1
         | 
| 14 | 
            +
                      if a[j]>a[j+1]
         | 
| 15 | 
            +
                          temp=a[j]
         | 
| 16 | 
            +
                          a[j]=a[j+1]
         | 
| 17 | 
            +
                          a[j+1]=temp
         | 
| 18 | 
            +
                      end
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                 end
         | 
| 21 | 
            +
                 return a
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
             | 
| 25 | 
            +
              def burbuja_each (a)
         | 
| 26 | 
            +
              		tmp = 0
         | 
| 27 | 
            +
                  array = Array.new
         | 
| 28 | 
            +
                  array = a
         | 
| 29 | 
            +
                  # nuevo = new.Array
         | 
| 30 | 
            +
                  #array = array2.split(" ")
         | 
| 31 | 
            +
              	   	(0..array.length-1).each do |i|
         | 
| 32 | 
            +
              	   		(0..array.length-2).each do |j|
         | 
| 33 | 
            +
              	   			if(array[j] > array[j+1])
         | 
| 34 | 
            +
              	   				tmp = array[j]
         | 
| 35 | 
            +
              	   				array[j] = array[j+1]
         | 
| 36 | 
            +
              	   				array[j+1] = tmp
         | 
| 37 | 
            +
              	   			end
         | 
| 38 | 
            +
              	   		end
         | 
| 39 | 
            +
              	   	end
         | 
| 40 | 
            +
              	   	return array;
         | 
| 41 | 
            +
              	end
         | 
| 42 | 
            +
            end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
             | 
| 45 | 
            +
            class Ordenacion
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            NUM_ALIMENTOS = 5
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            def self.description
         | 
| 50 | 
            +
               "clase que muestra informacion de nutrientes de un Alimento"
         | 
| 51 | 
            +
            end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
             | 
| 54 | 
            +
             | 
| 55 | 
            +
             | 
| 56 | 
            +
            attr_accessor :huevo_frito, :leche_de_vaca ,:yogurt ,:cerdo ,:ternera, :pollo ,:bacalao, :atun ,:salmon, :aceita_de_oliva ,:chocolate ,:azucar ,:arroz ,:lentejas, :papas, :tomate, :cebolla ,:manzana, :platano
         | 
| 57 | 
            +
            attr_accessor :alimentos
         | 
| 58 | 
            +
            def initialize ()
         | 
| 59 | 
            +
             | 
| 60 | 
            +
            @huevo_frito= ['Huevo',14.1,0.0,19.5]
         | 
| 61 | 
            +
            @leche_de_vaca = ['Leche de vaca',3.3,4.8,3.2]
         | 
| 62 | 
            +
            @yogurt = ['Yogurt',3.8,4.9,3.8]
         | 
| 63 | 
            +
            @cerdo = ['Cerdo',21.5,0.0,6.3]
         | 
| 64 | 
            +
            @ternera = ['Ternera',21.1,0.0,3.1]
         | 
| 65 | 
            +
            @pollo= ['Pollo',20.6,0.0,5.6]
         | 
| 66 | 
            +
            @bacalao = ['Bacalao',17.7,0.0,0.4]
         | 
| 67 | 
            +
            @atun = ['Atun',21.5,0.0,15.5]
         | 
| 68 | 
            +
            @salmon = ['Salmon',19.9,0.0,13.6]
         | 
| 69 | 
            +
            @aceita_de_oliva = ['Aceite de oliva',0.0,0.2,99.6]
         | 
| 70 | 
            +
            @chocolate = ['Chocolate',5.3,47.0,30.0]
         | 
| 71 | 
            +
            @azucar = ['Azucar',0.0,99.8,0.0]
         | 
| 72 | 
            +
            @arroz = ['Arroz',6.8,77.7,0.6]
         | 
| 73 | 
            +
            @lentejas = ['Lentejas',23.5,52.0,1.4]
         | 
| 74 | 
            +
            @papas = ['Papas',2.0,15.4,0.1]
         | 
| 75 | 
            +
            @tomate = ['Tomate',1.0,3.5,0.2]
         | 
| 76 | 
            +
            @cebolla = ['Cebolla',1.3,5.8,0.3]
         | 
| 77 | 
            +
            @manzana = ['Manzana',0.3,12.4,0.4]
         | 
| 78 | 
            +
            @platano = ['Platano',1.2,21.4,0.2]
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            @alimentos = [@huevo_frito,@leche_de_vaca,@yogurt,@cerdo,@ternera,@pollo,@bacalao,@atun,@salmon,@aceita_de_oliva,@chocolate,@azucar,@arroz,@lentejas,@papas,@tomate,@cebolla,@manzana,@platano]
         | 
| 81 | 
            +
            @alimentor = [@huevo_frito,@leche_de_vaca,@yogurt,@cerdo,@ternera,@pollo,@bacalao]
         | 
| 82 | 
            +
            @prueba_extrema = [999999,88888888,777777777,6666666,5555555,4444444,33333,22222,11111]
         | 
| 83 | 
            +
            @prueba_extrema2 = [9,8,7,6,5,4,3,2,1]
         | 
| 84 | 
            +
            end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
            def calculo_calorias (alimento,cantidad)
         | 
| 87 | 
            +
             | 
| 88 | 
            +
            #a = /\p{N}/.match (cantidad)
         | 
| 89 | 
            +
            number = cantidad.match(/\d+/)[0]
         | 
| 90 | 
            +
            #puts (number)
         | 
| 91 | 
            +
             | 
| 92 | 
            +
            result = []
         | 
| 93 | 
            +
             | 
| 94 | 
            +
            #@alimentor.each_with_index do |alimento,i|
         | 
| 95 | 
            +
            if (number.to_f > 3.0)
         | 
| 96 | 
            +
              result = (alimento[1]*4.0) + (alimento[2]*4.0) + (alimento[3]*9.0)
         | 
| 97 | 
            +
            else
         | 
| 98 | 
            +
              result = (alimento[1]*4.0*number.to_f) + (alimento[2]*4.0*number.to_f) + (alimento[3]*9.0*number.to_f)
         | 
| 99 | 
            +
            #result.to_s
         | 
| 100 | 
            +
            end
         | 
| 101 | 
            +
            #end
         | 
| 102 | 
            +
            return (result)
         | 
| 103 | 
            +
             | 
| 104 | 
            +
            end
         | 
| 105 | 
            +
             | 
| 106 | 
            +
             | 
| 107 | 
            +
             | 
| 108 | 
            +
             | 
| 109 | 
            +
              def to_s
         | 
| 110 | 
            +
             | 
| 111 | 
            +
                i = 0
         | 
| 112 | 
            +
                j = 0
         | 
| 113 | 
            +
             | 
| 114 | 
            +
                r = []
         | 
| 115 | 
            +
                #each_byte
         | 
| 116 | 
            +
            result = ""
         | 
| 117 | 
            +
            #a = [[11111,222222,33333333],[4444,5555,6666],[7777,88888,99999]]
         | 
| 118 | 
            +
                for i in 0...@alimentos.length-1
         | 
| 119 | 
            +
                  for j in 0...@alimentos.length-1
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                result << "#{@alimentos[i][j]}"
         | 
| 122 | 
            +
                result << " "
         | 
| 123 | 
            +
             | 
| 124 | 
            +
             | 
| 125 | 
            +
            end
         | 
| 126 | 
            +
            result << "\n"
         | 
| 127 | 
            +
              end
         | 
| 128 | 
            +
              return (result)
         | 
| 129 | 
            +
             | 
| 130 | 
            +
              end
         | 
| 131 | 
            +
             | 
| 132 | 
            +
            end #class
         | 
| 133 | 
            +
            #@a = []
         | 
| 134 | 
            +
             | 
| 135 | 
            +
            #################################################3
         | 
| 136 | 
            +
             | 
| 137 | 
            +
             | 
| 138 | 
            +
             | 
| 139 | 
            +
             | 
| 140 | 
            +
             | 
| 141 | 
            +
            #class Plato < Ordenacion
         | 
| 142 | 
            +
            class Plato
         | 
| 143 | 
            +
              attr_accessor :name, :vegetales, :frutas, :granos_integrales, :proteinas_saludables, :aceites, :aguas, :compo_nutri
         | 
| 144 | 
            +
              attr_accessor :agua, :aceite, :proteina, :cereal, :vegetal, :fruta
         | 
| 145 | 
            +
              attr_accessor :busqueda, :to_s
         | 
| 146 | 
            +
              def initialize(name, &block)
         | 
| 147 | 
            +
                #super (huevo_frito)
         | 
| 148 | 
            +
                @name = name
         | 
| 149 | 
            +
                @vegetales = []
         | 
| 150 | 
            +
                @frutas = []
         | 
| 151 | 
            +
                @granos_integrales = []
         | 
| 152 | 
            +
                @proteinas_saludables = []
         | 
| 153 | 
            +
                @aceites = []
         | 
| 154 | 
            +
                @aguas = []
         | 
| 155 | 
            +
                @compo_nutri = []
         | 
| 156 | 
            +
                @sumatorio = 0.0
         | 
| 157 | 
            +
             | 
| 158 | 
            +
             | 
| 159 | 
            +
            # super(huevo_frito,leche_de_vaca,yogurt,cerdo,ternera,pollo,bacalao,atun,salmon,aceita_de_oliva,chocolate,azucar,arroz,lentejas,papas,tomate,cebolla,manzana,platano)
         | 
| 160 | 
            +
            #super(alimentos)
         | 
| 161 | 
            +
             | 
| 162 | 
            +
                if block_given?
         | 
| 163 | 
            +
                  if block.arity == 1
         | 
| 164 | 
            +
                    yield self
         | 
| 165 | 
            +
                  else
         | 
| 166 | 
            +
                   instance_eval(&block)
         | 
| 167 | 
            +
                  end
         | 
| 168 | 
            +
                end
         | 
| 169 | 
            +
              end
         | 
| 170 | 
            +
             | 
| 171 | 
            +
            ###################################################################################
         | 
| 172 | 
            +
            #@alimentos es de la clase ordenacion
         | 
| 173 | 
            +
            #elemento = alimento
         | 
| 174 | 
            +
            #arreglar
         | 
| 175 | 
            +
             | 
| 176 | 
            +
            def busqueda(ingrediente,cantidad)
         | 
| 177 | 
            +
              @datos = Ordenacion.new()
         | 
| 178 | 
            +
             | 
| 179 | 
            +
            final = ""
         | 
| 180 | 
            +
            retorna = ""
         | 
| 181 | 
            +
            salida = ""
         | 
| 182 | 
            +
                @datos.alimentos.each_with_index do |alimento, index|
         | 
| 183 | 
            +
             | 
| 184 | 
            +
                    if (ingrediente == alimento[0])
         | 
| 185 | 
            +
                      #puts (alimento[0])
         | 
| 186 | 
            +
                      result = @datos.calculo_calorias(alimento,cantidad)
         | 
| 187 | 
            +
                      @sumatorio += result
         | 
| 188 | 
            +
                      #puts (@sumatorio)
         | 
| 189 | 
            +
                      a = alimento[0].to_s
         | 
| 190 | 
            +
                      b = alimento[1].to_s
         | 
| 191 | 
            +
                      c = alimento[2].to_s
         | 
| 192 | 
            +
                      d = alimento[3].to_s
         | 
| 193 | 
            +
                      e = result.to_s
         | 
| 194 | 
            +
                      retorna <<" "<<a.ljust(15) <<" "<< b.ljust(8) <<" "<< c.ljust(9) <<" "<< d.ljust(5) <<"   "<< e.ljust(25) << " "
         | 
| 195 | 
            +
                    end
         | 
| 196 | 
            +
                    salida = retorna
         | 
| 197 | 
            +
                end
         | 
| 198 | 
            +
                final = salida
         | 
| 199 | 
            +
            final
         | 
| 200 | 
            +
             | 
| 201 | 
            +
            end
         | 
| 202 | 
            +
             | 
| 203 | 
            +
              def to_s
         | 
| 204 | 
            +
                output = @name
         | 
| 205 | 
            +
                output << "\n#{'=' * @name.size}\n"
         | 
| 206 | 
            +
                output << "Composicion Nutricional:\n"
         | 
| 207 | 
            +
                output << "                 glúcidos proteı́nas lı́pidos valor energético\n"
         | 
| 208 | 
            +
             | 
| 209 | 
            +
            a = []
         | 
| 210 | 
            +
            b = []
         | 
| 211 | 
            +
            #p (@compo_nutri)
         | 
| 212 | 
            +
                @compo_nutri.each_with_index do |ingrediente,index|
         | 
| 213 | 
            +
             | 
| 214 | 
            +
             | 
| 215 | 
            +
                   output << busqueda(ingrediente[0],ingrediente[1]).to_s
         | 
| 216 | 
            +
            #p (ingrediente[0])
         | 
| 217 | 
            +
            #p (ingrediente[1])
         | 
| 218 | 
            +
                  output << "\n"
         | 
| 219 | 
            +
             | 
| 220 | 
            +
                end
         | 
| 221 | 
            +
            output << "Valor energético total " << @sumatorio.to_s
         | 
| 222 | 
            +
             | 
| 223 | 
            +
            output
         | 
| 224 | 
            +
             end
         | 
| 225 | 
            +
             | 
| 226 | 
            +
            ################################################################################
         | 
| 227 | 
            +
             | 
| 228 | 
            +
              def vegetal(text, options = {})
         | 
| 229 | 
            +
                alimento = [text]
         | 
| 230 | 
            +
                alimento <<"(#{options[:porcion]})" if options[:porcion]
         | 
| 231 | 
            +
                @compo_nutri << alimento
         | 
| 232 | 
            +
              end
         | 
| 233 | 
            +
             | 
| 234 | 
            +
              def fruta(text, options = {})
         | 
| 235 | 
            +
                alimento = [text]
         | 
| 236 | 
            +
                alimento <<"(#{options[:gramos]})" if options[:gramos]
         | 
| 237 | 
            +
                @compo_nutri << alimento
         | 
| 238 | 
            +
              end
         | 
| 239 | 
            +
             | 
| 240 | 
            +
              def cereal(text, options = {})
         | 
| 241 | 
            +
                alimento = [text]
         | 
| 242 | 
            +
                alimento <<"(#{options[:porcion]})" if options[:porcion]
         | 
| 243 | 
            +
                @compo_nutri << alimento
         | 
| 244 | 
            +
              end
         | 
| 245 | 
            +
             | 
| 246 | 
            +
              def proteina(text, options = {})
         | 
| 247 | 
            +
                alimento = [text]
         | 
| 248 | 
            +
                alimento <<"(#{options[:porcion]})" if options[:porcion]
         | 
| 249 | 
            +
                @compo_nutri << alimento
         | 
| 250 | 
            +
              end
         | 
| 251 | 
            +
             | 
| 252 | 
            +
              def aceite(text, options = {})
         | 
| 253 | 
            +
                alimento = [text]
         | 
| 254 | 
            +
                alimento <<"(#{options[:porcion]})" if options[:porcion]
         | 
| 255 | 
            +
                @compo_nutri << alimento
         | 
| 256 | 
            +
              end
         | 
| 257 | 
            +
             | 
| 258 | 
            +
              def agua(text, options = {})
         | 
| 259 | 
            +
                alimento = [text]
         | 
| 260 | 
            +
                alimento <<"(#{[options[:litros]]})" if options[:litros]
         | 
| 261 | 
            +
                @compo_nutri << alimento
         | 
| 262 | 
            +
              end
         | 
| 263 | 
            +
            end
         | 
| 264 | 
            +
             | 
| 265 | 
            +
            lentejas_arroz = Plato.new("Lentejas con arroz, salsa de tomate, huevo y platano a la plancha") do
         | 
| 266 | 
            +
            vegetal "Tomate",:porcion => "2 piezas pequeñas"
         | 
| 267 | 
            +
            fruta "Platano",:gramos => 20
         | 
| 268 | 
            +
            cereal "Arroz",:porcion => "1 taza"
         | 
| 269 | 
            +
            proteina "Lentejas",:porcion => "1/2 cucharon"
         | 
| 270 | 
            +
            aceite "Aceite de oliva",:porcion => "1/2 cucharada"
         | 
| 271 | 
            +
            proteina "Huevo",:porcion => "1 pieza"
         | 
| 272 | 
            +
            end
         | 
| 273 | 
            +
            puts lentejas_arroz
         | 
| 274 | 
            +
            #puts lentejas_arroz.to_s
         | 
| 275 | 
            +
            #ya funciona la otra clase
         | 
| 276 | 
            +
             | 
| 277 | 
            +
             | 
| 278 | 
            +
             | 
| 279 | 
            +
             | 
| 280 | 
            +
             | 
| 281 | 
            +
             | 
| 282 | 
            +
             | 
| 283 | 
            +
             | 
| 284 | 
            +
             | 
| 285 | 
            +
             | 
| 286 | 
            +
             | 
| 287 | 
            +
             | 
| 288 | 
            +
             | 
| 289 | 
            +
             | 
| 290 | 
            +
             | 
| 291 | 
            +
             | 
| 292 | 
            +
            # @prueba = Ordenacion.new
         | 
| 293 | 
            +
            # puts ('************* ELEMENTOS SIN ORDENAR *********************************')
         | 
| 294 | 
            +
            #
         | 
| 295 | 
            +
            # @a = @prueba.calculo_calorias
         | 
| 296 | 
            +
            # #@a.to_a
         | 
| 297 | 
            +
            # p(@a)
         | 
| 298 | 
            +
            #
         | 
| 299 | 
            +
            # puts ('**************** ELEMENTOS ORDENADOS CON BUCLE FOR ********************')
         | 
| 300 | 
            +
            # @b = @prueba.burbuja_for(@a)
         | 
| 301 | 
            +
            # p(@b)
         | 
| 302 | 
            +
            #
         | 
| 303 | 
            +
            # puts ('************** ELEMENTOS ORDENADOS CON BUCLE EACH ******************************')
         | 
| 304 | 
            +
            # @b = @prueba.burbuja_each(@a)
         | 
| 305 | 
            +
            # p(@b)
         | 
| 306 | 
            +
            #
         | 
| 307 | 
            +
            # puts ('***************** ELEMENTOS ORDENADOS METODO SORT ****************')
         | 
| 308 | 
            +
            # @b = @a.sort
         | 
| 309 | 
            +
            # p(@b)
         | 
| 310 | 
            +
            #
         | 
| 311 | 
            +
            # # @texto = @prueba.to_s
         | 
| 312 | 
            +
            # # puts(@texto)
         | 
| 313 | 
            +
            #
         | 
| 314 | 
            +
            #
         | 
| 315 | 
            +
            #
         | 
| 316 | 
            +
            #
         | 
| 317 | 
            +
            # Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x|
         | 
| 318 | 
            +
            #   tf = x.report("con bucle for")   { @prueba.burbuja_for(@a) }
         | 
| 319 | 
            +
            #   tf = x.report("con bucle each")   { @prueba.burbuja_each(@a) }
         | 
| 320 | 
            +
            #   tf = x.report("con metodo sort")   { @a.sort }
         | 
| 321 | 
            +
            # end
         | 
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            require "Alimento/alimentos.rb"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
             | 
| 4 | 
            +
            class Tipo_alimento < Alimentos
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              def self.description
         | 
| 7 | 
            +
                 "clase que representa el tipo de aliment"
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            attr_accessor :tipo_alimento
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            def initialize (nombre_ali,proteinas,glucidos,lipidos,tipo_ali)
         | 
| 13 | 
            +
              super(nombre_ali,proteinas,glucidos,lipidos)
         | 
| 14 | 
            +
              @tipo_ali = tipo_ali
         | 
| 15 | 
            +
            end
         | 
| 16 | 
            +
            def to_s
         | 
| 17 | 
            +
              s =  ""    #encadenamiento (chaining)
         | 
| 18 | 
            +
              s << "#{@tipo_ali}\n"
         | 
| 19 | 
            +
              s << super.to_s
         | 
| 20 | 
            +
              s
         | 
| 21 | 
            +
            end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
             | 
| 24 | 
            +
             | 
| 25 | 
            +
            end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
             | 
| 28 | 
            +
            # @tipo_ali_1 = Tipo_alimento.new("huevo frito",14.1,0.0,19.5,"huevos lacteos y helados")
         | 
| 29 | 
            +
            # puts (@tipo_ali_1.to_s)
         | 
    
        data/lib/Alimento.rb
    ADDED
    
    | @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            require "Alimento/version"
         | 
| 2 | 
            +
            require "Alimento/alimentos.rb"
         | 
| 3 | 
            +
            require "Alimento/tipo_alimento.rb"
         | 
| 4 | 
            +
            require "Alimento/lista_doble.rb"
         | 
| 5 | 
            +
            require "Alimento/glucemico.rb"
         | 
| 6 | 
            +
            require "Alimento/ordenacion.rb"
         | 
| 7 | 
            +
            require "Alimento/dsl.rb"
         | 
| 8 | 
            +
            module Alimento
         | 
| 9 | 
            +
              # require "Alimento/alimentos.rb"
         | 
| 10 | 
            +
              # require "Alimento/tipo_alimento.rb"
         | 
| 11 | 
            +
              # require "Alimento/lista_doble.rb"
         | 
| 12 | 
            +
              # Your code goes here...
         | 
| 13 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,177 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: Alimento
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Miguel Parra
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: exe
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2017-12-13 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.15'
         | 
| 20 | 
            +
              type: :development
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '1.15'
         | 
| 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: coveralls
         | 
| 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 | 
            +
            description: una clase con herencia y una lista doblemente enlazada
         | 
| 112 | 
            +
            email:
         | 
| 113 | 
            +
            - alu0100200393@ull.edu.es
         | 
| 114 | 
            +
            executables: []
         | 
| 115 | 
            +
            extensions: []
         | 
| 116 | 
            +
            extra_rdoc_files: []
         | 
| 117 | 
            +
            files:
         | 
| 118 | 
            +
            - ".coveralls.yml"
         | 
| 119 | 
            +
            - ".gitignore"
         | 
| 120 | 
            +
            - ".rake_tasks~"
         | 
| 121 | 
            +
            - ".rspec"
         | 
| 122 | 
            +
            - ".travis.yml"
         | 
| 123 | 
            +
            - Alimento.gemspec
         | 
| 124 | 
            +
            - Gemfile
         | 
| 125 | 
            +
            - Guardfile
         | 
| 126 | 
            +
            - README.md
         | 
| 127 | 
            +
            - Rakefile
         | 
| 128 | 
            +
            - bin/console
         | 
| 129 | 
            +
            - bin/setup
         | 
| 130 | 
            +
            - docs/Alimentos.html
         | 
| 131 | 
            +
            - docs/ListaDoble.html
         | 
| 132 | 
            +
            - docs/Nodo.html
         | 
| 133 | 
            +
            - docs/_index.html
         | 
| 134 | 
            +
            - docs/class_list.html
         | 
| 135 | 
            +
            - docs/css/common.css
         | 
| 136 | 
            +
            - docs/css/full_list.css
         | 
| 137 | 
            +
            - docs/css/style.css
         | 
| 138 | 
            +
            - docs/file.README.html
         | 
| 139 | 
            +
            - docs/file_list.html
         | 
| 140 | 
            +
            - docs/frames.html
         | 
| 141 | 
            +
            - docs/index.html
         | 
| 142 | 
            +
            - docs/js/app.js
         | 
| 143 | 
            +
            - docs/js/full_list.js
         | 
| 144 | 
            +
            - docs/js/jquery.js
         | 
| 145 | 
            +
            - docs/method_list.html
         | 
| 146 | 
            +
            - docs/top-level-namespace.html
         | 
| 147 | 
            +
            - lib/Alimento.rb
         | 
| 148 | 
            +
            - lib/Alimento/alimentos.rb
         | 
| 149 | 
            +
            - lib/Alimento/glucemico.rb
         | 
| 150 | 
            +
            - lib/Alimento/lista_doble.rb
         | 
| 151 | 
            +
            - lib/Alimento/ordenacion.rb
         | 
| 152 | 
            +
            - lib/Alimento/tipo_alimento.rb
         | 
| 153 | 
            +
            - lib/Alimento/version.rb
         | 
| 154 | 
            +
            homepage: https://github.com/ULL-ESIT-LPP-1718/tdd-miguelpe83
         | 
| 155 | 
            +
            licenses: []
         | 
| 156 | 
            +
            metadata: {}
         | 
| 157 | 
            +
            post_install_message: 
         | 
| 158 | 
            +
            rdoc_options: []
         | 
| 159 | 
            +
            require_paths:
         | 
| 160 | 
            +
            - lib
         | 
| 161 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 162 | 
            +
              requirements:
         | 
| 163 | 
            +
              - - ">="
         | 
| 164 | 
            +
                - !ruby/object:Gem::Version
         | 
| 165 | 
            +
                  version: '0'
         | 
| 166 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 167 | 
            +
              requirements:
         | 
| 168 | 
            +
              - - ">="
         | 
| 169 | 
            +
                - !ruby/object:Gem::Version
         | 
| 170 | 
            +
                  version: '0'
         | 
| 171 | 
            +
            requirements: []
         | 
| 172 | 
            +
            rubyforge_project: 
         | 
| 173 | 
            +
            rubygems_version: 2.5.2
         | 
| 174 | 
            +
            signing_key: 
         | 
| 175 | 
            +
            specification_version: 4
         | 
| 176 | 
            +
            summary: clase con alimentos y tipo de alimentos
         | 
| 177 | 
            +
            test_files: []
         |