Class: DLinked::CacheList::Node

Inherits:
List::Node show all
Defined in:
lib/d_linked/cache_list.rb

Instance Attribute Summary collapse

Attributes inherited from List::Node

#next, #prev, #value

Instance Method Summary collapse

Constructor Details

#initialize(value, prev = nil, next_node = nil, key = nil) ⇒ Node

IMPORTANT: Accept the required three arguments from the base List#prepend, but only initialize the base class with value, prev, and next.



24
25
26
27
28
29
30
# File 'lib/d_linked/cache_list.rb', line 24

def initialize(value, prev = nil, next_node = nil, key = nil)
  # Call the parent Node initializer using the first three arguments
  super(value, prev, next_node) 
  
  # Initialize the new, specialized attribute
  @key = key
end

Instance Attribute Details

#keyObject

Add an attribute to hold the cache key



20
21
22
# File 'lib/d_linked/cache_list.rb', line 20

def key
  @key
end