Class: DLinked::CacheList::Node

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

Overview

A specialized node for the ‘CacheList` that includes a `key`.

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

Initializes a new CacheList Node.

Parameters:

  • value (Object)

    The value to store in the node.

  • prev (Node, nil) (defaults to: nil)

    The preceding node.

  • next_node (Node, nil) (defaults to: nil)

    The succeeding node.

  • key (Object) (defaults to: nil)

    The cache key for this node.



56
57
58
59
# File 'lib/d_linked/cache_list.rb', line 56

def initialize(value, prev = nil, next_node = nil, key = nil)
  super(value, prev, next_node)
  @key = key
end

Instance Attribute Details

#keyObject

Returns The cache key associated with this node.

Returns:

  • (Object)

    The cache key associated with this node.



49
50
51
# File 'lib/d_linked/cache_list.rb', line 49

def key
  @key
end