Class: Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(info, previous: nil, _next: nil) ⇒ Node

Returns a new instance of Node.



5
6
7
8
9
# File 'lib/node.rb', line 5

def initialize(info, previous: nil, _next: nil)
  @info = info
  @next = _next
  @previous = previous
end

Instance Attribute Details

#infoObject

Returns the value of attribute info.



3
4
5
# File 'lib/node.rb', line 3

def info
  @info
end

#nextObject

Returns the value of attribute next.



3
4
5
# File 'lib/node.rb', line 3

def next
  @next
end

#previousObject

Returns the value of attribute previous.



3
4
5
# File 'lib/node.rb', line 3

def previous
  @previous
end

Instance Method Details

#to_sObject



11
12
13
14
15
# File 'lib/node.rb', line 11

def to_s
  s = (info == nil)? "nil": "#{@info}"
  s << ", " if @next != nil
  s
end