Method: List#insert

Defined in:
lib/nutrientes/list.rb

#insert(nodo) ⇒ Object

Inserts a node at the end of the list

Parameters:

  • nodo (Object)

    node to insert

Returns:

  • nil



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/nutrientes/list.rb', line 69

def insert(nodo)
    if @size == 0 then
        @head = nodo
        @tail = nodo
    else
        @head.nodo[:prev_] = nodo
        nodo.nodo[:next_] = @head
        @head = nodo
    end
    @size += 1
end