Class: Node

Inherits:
Struct
  • Object
show all
Includes:
Comparable
Defined in:
lib/prct06/list.rb,
lib/prct06/list.rb

Overview

create a Struct with :value, :next and :prev

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nexObject

Returns the value of attribute nex

Returns:

  • (Object)

    the current value of nex



2
3
4
# File 'lib/prct06/list.rb', line 2

def nex
  @nex
end

#prevObject

Returns the value of attribute prev

Returns:

  • (Object)

    the current value of prev



2
3
4
# File 'lib/prct06/list.rb', line 2

def prev
  @prev
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



2
3
4
# File 'lib/prct06/list.rb', line 2

def value
  @value
end

Instance Method Details

#<=>(anOther) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/prct06/list.rb', line 6

def <=>(anOther)
  if anOther.is_a?(Node)
    value <=> anOther.value
  else
    value <=> anOther
  end
end

#to_sObject



13
14
15
# File 'lib/prct06/list.rb', line 13

def to_s
  to_return = "(Value: #{value})"
end