Class: Link

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key = nil, val = nil) ⇒ Link

Returns a new instance of Link.



4
5
6
7
8
9
# File 'lib/simms_structures/linked_list.rb', line 4

def initialize(key = nil, val = nil)
  @key = key
  @val = val
  @next = nil
  @prev = nil
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



2
3
4
# File 'lib/simms_structures/linked_list.rb', line 2

def key
  @key
end

#nextObject

Returns the value of attribute next.



2
3
4
# File 'lib/simms_structures/linked_list.rb', line 2

def next
  @next
end

#prevObject

Returns the value of attribute prev.



2
3
4
# File 'lib/simms_structures/linked_list.rb', line 2

def prev
  @prev
end

#valObject

Returns the value of attribute val.



2
3
4
# File 'lib/simms_structures/linked_list.rb', line 2

def val
  @val
end

Instance Method Details

#to_sObject



11
12
13
# File 'lib/simms_structures/linked_list.rb', line 11

def to_s
  "#{@key}: #{@val}"
end