class LinkedListNode

Attributes

next[R]
prev[R]
value[RW]

Public Class Methods

new(value = nil) click to toggle source
# File lib/linked_list_node.rb, line 5
def initialize(value = nil)
  raise "Error in LinkedListNode::new - value is a LinkedListNode instance" if value.class == LinkedListNode

  @value = value
  @prev = nil
  @next = nil
end

Public Instance Methods

next=(other_node) click to toggle source
# File lib/linked_list_node.rb, line 18
def next=(other_node)
  _validate_node(other_node, :next)
  @next = other_node
end
prev=(other_node) click to toggle source
# File lib/linked_list_node.rb, line 13
def prev=(other_node)
  _validate_node(other_node, :prev)
  @prev = other_node
end

Private Instance Methods

_validate_node(node, function_name) click to toggle source
# File lib/linked_list_node.rb, line 25
def _validate_node(node, function_name)
  raise "Error in LinkedListNode##{function_name} - other_node is not a LinkedListNode instance" unless node.class == LinkedListNode || node.nil?
end