Class: LinkedList::DoublyNode
- Inherits:
-
Object
- Object
- LinkedList::DoublyNode
- Defined in:
- lib/linked_list_sourav.rb
Instance Attribute Summary collapse
-
#backward ⇒ Object
Returns the value of attribute backward.
-
#data ⇒ Object
Returns the value of attribute data.
-
#forward ⇒ Object
Returns the value of attribute forward.
Instance Method Summary collapse
-
#initialize(data, backward = nil, forward = nil) ⇒ DoublyNode
constructor
A new instance of DoublyNode.
- #to_s ⇒ Object
Constructor Details
#initialize(data, backward = nil, forward = nil) ⇒ DoublyNode
Returns a new instance of DoublyNode.
21 22 23 24 25 26 |
# File 'lib/linked_list_sourav.rb', line 21 def initialize(data, backward=nil, forward=nil) @data = data @backward = backward @forward = forward self end |
Instance Attribute Details
#backward ⇒ Object
Returns the value of attribute backward.
20 21 22 |
# File 'lib/linked_list_sourav.rb', line 20 def backward @backward end |
#data ⇒ Object
Returns the value of attribute data.
20 21 22 |
# File 'lib/linked_list_sourav.rb', line 20 def data @data end |
#forward ⇒ Object
Returns the value of attribute forward.
20 21 22 |
# File 'lib/linked_list_sourav.rb', line 20 def forward @forward end |
Instance Method Details
#to_s ⇒ Object
28 29 30 31 32 33 |
# File 'lib/linked_list_sourav.rb', line 28 def to_s string = "Data: #{self.data} " string << "Points to: #{self.forward.data}" if self.forward string << " Pointed by: #{self.backward.data}" if self.backward string end |