Class: DataStructures101::LinkedList::Node
- Inherits:
-
Object
- Object
- DataStructures101::LinkedList::Node
- 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
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(value, previous_node = nil, next_node = nil) ⇒ Node
constructor
A new instance of Node.
- #to_s ⇒ Object
Constructor Details
#initialize(value, previous_node = nil, next_node = nil) ⇒ Node
Returns a new instance of Node.
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
#next ⇒ Object
15 16 17 |
# File 'lib/data_structures_101/linked_list.rb', line 15 def next @next end |
#prev ⇒ Object
15 16 17 |
# File 'lib/data_structures_101/linked_list.rb', line 15 def prev @prev end |
#value ⇒ Object
15 16 17 |
# File 'lib/data_structures_101/linked_list.rb', line 15 def value @value end |
Instance Method Details
#to_s ⇒ Object
23 24 25 |
# File 'lib/data_structures_101/linked_list.rb', line 23 def to_s "<value=#{value}>" end |