Class: DataStructures101::LinkedList::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, prev = nil, _next = nil) ⇒ Node

Returns a new instance of Node.



9
10
11
12
13
# File 'lib/data_structures_101/linked_list.rb', line 9

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

Instance Attribute Details

#nextObject

Returns the value of attribute next.



7
8
9
# File 'lib/data_structures_101/linked_list.rb', line 7

def next
  @next
end

#prevObject

Returns the value of attribute prev.



7
8
9
# File 'lib/data_structures_101/linked_list.rb', line 7

def prev
  @prev
end

#valueObject

Returns the value of attribute value.



7
8
9
# File 'lib/data_structures_101/linked_list.rb', line 7

def value
  @value
end

Instance Method Details

#to_sObject



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

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