class Lista attr_accessor :top, :last Node = Struct.new(:value, :prev, :next) def initialize(top) if top === nil @top = nil @last = nil else @top = Node.new(top,nil,nil) @last = Node.new(top,nil,nil) end end def insertarMultiple(elementos) elementos.each do |elemento| insertar(elemento) end end def insertar(elemento) if empty @top = Node.new(elemento,nil, nil) @last = Node.new(elemento,nil, nil) else @top[:next] = elemento; nmenu = Node.new(elemento, @top, nil) @top = nmenu end end def mostrarUltimo if empty puts "Lista vacia. Empty!" else aux = @top; while aux[:prev] != nil aux = aux[:prev] end aux[:value] end end def getPrevTop aux = top[:prev] val = aux[:value] val end def extraer if empty puts "Lista vacia. Empty!" else extraer = @top[:value] aux_to = @top[:prev] if @top == @last @last = nil; end aux_to[:next] = nil @top = aux_to extraer end end def empty if @top == nil true else false end end end