Class: DataStructures101::LinkedList::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/data_structures_101/linked_list.rb

Overview

Internal class to store a given value in the LinkedList. Provides reference to next and previous node in the list

See Also:

Author:

  • Rene Hernandez

Since:

  • 0.1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, previous_node = nil, next_node = nil) ⇒ Node

Returns a new instance of Node.

Since:

  • 0.1



17
18
19
20
21
# File 'lib/data_structures_101/linked_list.rb', line 17

def initialize(value, previous_node = nil, next_node = nil)
  @value = value
  @prev = previous_node
  @next = next_node
end

Instance Attribute Details

#nextObject

Since:

  • 0.1



15
16
17
# File 'lib/data_structures_101/linked_list.rb', line 15

def next
  @next
end

#prevObject

Since:

  • 0.1



15
16
17
# File 'lib/data_structures_101/linked_list.rb', line 15

def prev
  @prev
end

#valueObject

Since:

  • 0.1



15
16
17
# File 'lib/data_structures_101/linked_list.rb', line 15

def value
  @value
end

Instance Method Details

#to_sObject

Since:

  • 0.1



23
24
25
# File 'lib/data_structures_101/linked_list.rb', line 23

def to_s
  "<value=#{value}>"
end