Class: Node

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

Overview

Representación de un nodo que tendrá su valor, la dirección del siguiente nodo y la del anterior. Esta clase será usada posteriormente por la clase List.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#anteriorObject

Returns the value of attribute anterior

Returns:

  • (Object)

    the current value of anterior



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

def anterior
  @anterior
end

#nextObject

Returns the value of attribute next

Returns:

  • (Object)

    the current value of next



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

def next
  @next
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



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

def value
  @value
end

Instance Method Details

#<=>(other) ⇒ Object

Método que se ha de implementar al incluir el Mixin Comparable y con el que se hace la comparativa entre el valor del nodo y otro pasado por parámetro



9
10
11
# File 'lib/exam/list.rb', line 9

def <=> (other)
   value <=> other.value
end