Class: DDQL::LinkedList::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, next_node: nil, previous_node: nil) ⇒ Node

Returns a new instance of Node.



12
13
14
15
16
# File 'lib/ddql/linked_list.rb', line 12

def initialize(value, next_node: nil, previous_node: nil)
  @next     = next_node
  @previous = previous_node
  @value    = value
end

Instance Attribute Details

#nextObject

Returns the value of attribute next.



9
10
11
# File 'lib/ddql/linked_list.rb', line 9

def next
  @next
end

#previousObject

Returns the value of attribute previous.



9
10
11
# File 'lib/ddql/linked_list.rb', line 9

def previous
  @previous
end

#valueObject (readonly)

Returns the value of attribute value.



10
11
12
# File 'lib/ddql/linked_list.rb', line 10

def value
  @value
end

Instance Method Details

#to_sObject



18
19
20
# File 'lib/ddql/linked_list.rb', line 18

def to_s
  "Node[#{@value}]"
end