Class: LinkedList::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/linked-list/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Node

Returns a new instance of Node.



7
8
9
10
11
# File 'lib/linked-list/node.rb', line 7

def initialize(data)
  @data = data
  @next = nil
  @prev = nil
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/linked-list/node.rb', line 5

def data
  @data
end

#nextObject

Returns the value of attribute next.



5
6
7
# File 'lib/linked-list/node.rb', line 5

def next
  @next
end

#prevObject

Returns the value of attribute prev.



5
6
7
# File 'lib/linked-list/node.rb', line 5

def prev
  @prev
end

Instance Method Details

#to_nodeObject

Conversion function, see Conversions.Node.

Returns:

self



18
19
20
# File 'lib/linked-list/node.rb', line 18

def to_node
  self
end