Class: Nodo

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

Overview

Nodo como objeto comparable y ordenable (se mira el valor que contiene)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(valor) ⇒ Nodo

Constructor



9
10
11
12
13
# File 'lib/exam/nodo.rb', line 9

def initialize(valor)
	@valor = valor
	@id = object_id	#identificador univoco
	@next = nil
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#nextObject

Returns the value of attribute next.



6
7
8
# File 'lib/exam/nodo.rb', line 6

def next
  @next
end

#previusObject

Returns the value of attribute previus

Returns:

  • (Object)

    the current value of previus



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

def previus
  @previus
end

#valorObject (readonly)

Returns the value of attribute valor.



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

def valor
  @valor
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



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

def value
  @value
end

Instance Method Details

#<=>(other) ⇒ Object



10
11
12
# File 'lib/exam/lista.rb', line 10

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