class Project
Attributes
head[RW]
tail[RW]
Public Class Methods
new(head)
click to toggle source
Creates a new simple/linked list.
@param head the first node to insert @return [Project] the simple/linked list created.
# File lib/Project.rb, line 8 def initialize (head) @head = head @tail = head end
Public Instance Methods
add(node)
click to toggle source
Adds a node to a simple/linked list.
@param node node to add.
# File lib/Project.rb, line 17 def add(node) @tail.next = node node.prev=@tail @tail = @tail.next end
each() { |value| ... }
click to toggle source
Definition of each for Enumerable operations.
# File lib/Project.rb, line 41 def each current_node = @head while current_node != nil yield current_node.value current_node = current_node.next end end
to_s()
click to toggle source
prints the simple/linked list.
@return [String] every single node to string.
# File lib/Project.rb, line 26 def to_s() out = String.new current_node = @head while current_node != nil out << "#{current_node.value.to_s}" current_node = current_node.next out << "\n" end return out end