Skip to content

Commit

Permalink
Añadida función size
Browse files Browse the repository at this point in the history
  • Loading branch information
alu0100836400 committed Dec 18, 2018
1 parent 408c6c6 commit c097f5b
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion alimento/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source "https://rubygems.org"

gem 'coveralls', require: false
#gem 'coveralls', require: false #coveralls???
gem 'rspec'
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

Expand Down
5 changes: 5 additions & 0 deletions alimento/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ desc "Pruebas lista"
task :spec do
sh "rspec -I. spec/lista_spec.rb"
end

desc "Pruebas individuo"
task :spec do
sh "rspec -I. spec/individuo_spec.rb"
end
7 changes: 6 additions & 1 deletion alimento/lib/alimento/lista.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ class Lista

include Enumerable

attr_reader :cabeza, :cola
attr_reader :cabeza, :cola, :size

def initialize()
@cabeza = nil
@cola = nil
@size = 0
end

def insertar_cabeza(dato)
Expand All @@ -26,6 +27,7 @@ def insertar_cabeza(dato)
@cabeza.siguiente = @nuevo
end
@cabeza = @nuevo
@size += 1
end

def insertar_cola(dato)
Expand All @@ -43,6 +45,7 @@ def insertar_cola(dato)
@cola.anterior = @nuevo
end
@cola = @nuevo
@size += 1
end

def extraer_cabeza
Expand All @@ -54,6 +57,7 @@ def extraer_cabeza
@cabeza.siguiente = nil
@aux
end
@size -= 1
end

def extraer_cola
Expand All @@ -65,6 +69,7 @@ def extraer_cola
@cola.anterior = nil
@aux
end
@size -= 1
end

def empty
Expand Down
6 changes: 6 additions & 0 deletions alimento/lib/alimento/menu.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class Menu

include Comparable

attr_reader :listaComidas, :total

def initialize(listaComidas)
Expand All @@ -14,4 +16,8 @@ def cantidad_calorica
end
end

def <=>(otro)
@total <=> otro.total
end

end
Empty file added alimento/spec/array_spec.rb
Empty file.
4 changes: 4 additions & 0 deletions alimento/spec/lista_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@
@lista.extraer_cola()
expect(@lista.cabeza).to eq(@nodo2)
end

it "Se puede conocer el tamaño" do
expect(@lista.size).to eq(1)
end
end

context "Lista de etiquetas" do
Expand Down
1 change: 0 additions & 1 deletion alimento/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'coveralls'
Coveralls.wear!


require "./lib/alimento/lista.rb"
require "./lib/alimento/etiqueta.rb"
require "./lib/alimento/individuo.rb"
Expand Down

0 comments on commit c097f5b

Please sign in to comment.