Method: List#insert

Defined in:
lib/pract6/List.rb

#insert(nodo) ⇒ Object

Este método permite meter nodos en la lista



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/pract6/List.rb', line 39

def insert(nodo)
    if @head == nil
      @head = nodo
      @tail = @head
    elsif @head == @tail
      @tail.prev = nodo
      nodo.next = @tail
      @head = nodo
    else
      @head.prev = nodo
      nodo.next = @head
      @head = nodo
    end
end