Class: LinkedList::Node
- Inherits:
- 
      Object
      
        - Object
- LinkedList::Node
 
- Defined in:
- lib/linked_list_sourav.rb
Overview
this class defines one node the basic building blog of linked list
Instance Attribute Summary collapse
- 
  
    
      #data  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    data for holding data and forwards refers to next node. 
- 
  
    
      #forward  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    data for holding data and forwards refers to next node. 
Instance Method Summary collapse
- 
  
    
      #initialize(data, forward = nil)  ⇒ Node 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    intializes when new is invoked. 
- #to_s ⇒ Object
Constructor Details
#initialize(data, forward = nil) ⇒ Node
intializes when new is invoked
| 6 7 8 9 10 | # File 'lib/linked_list_sourav.rb', line 6 def initialize(data, forward = nil) #intializes when new is invoked @data = data @forward = forward self end | 
Instance Attribute Details
#data ⇒ Object
data for holding data and forwards refers to next node
| 4 5 6 | # File 'lib/linked_list_sourav.rb', line 4 def data @data end | 
#forward ⇒ Object
data for holding data and forwards refers to next node
| 4 5 6 | # File 'lib/linked_list_sourav.rb', line 4 def forward @forward end | 
Instance Method Details
#to_s ⇒ Object
| 12 13 14 15 16 | # File 'lib/linked_list_sourav.rb', line 12 def to_s string = "Data: #{self.data} " string << "Points to: #{self.forward.data}" if self.forward string end |