Class: Node

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

Overview

List.rb

Autor

Dailos Sabina Rodriguez

Autor

Raul Perez Hernandez

Clase Node

DefiniciĆ³n de la clase Node que permite almacenar y representar un nodo con un elemento anterior y otor posterior por pantalla mediante los siguientes metodos

  • metodo initialize

  • metodo to_s

  • metodo dev_value

  • metodo dev_sig

  • metodo dev_ant

  • metodo mod_sig

  • metodo mod_ant

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, sig, ant) ⇒ Node

Metodo para inicializar la clase



20
21
22
23
24
# File 'lib/List.rb', line 20

def initialize (value, sig, ant)
  @value = value
  @sig = sig
  @ant = ant
end

Instance Attribute Details

#antObject

Returns the value of attribute ant

Returns:

  • (Object)

    the current value of ant



18
19
20
# File 'lib/List.rb', line 18

def ant
  @ant
end

#sigObject

Returns the value of attribute sig

Returns:

  • (Object)

    the current value of sig



18
19
20
# File 'lib/List.rb', line 18

def sig
  @sig
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



18
19
20
# File 'lib/List.rb', line 18

def value
  @value
end

Instance Method Details

#dev_antObject

Funcion para obtener el puntero al anterior de un nodo



46
47
48
# File 'lib/List.rb', line 46

def dev_ant
  return @ant
end

#dev_sigObject

Funcion para obtener el puntero a siguiente de un nodo



41
42
43
# File 'lib/List.rb', line 41

def dev_sig
  return @sig
end

#dev_valueObject

Funcion para obtener el valor de un nodo



36
37
38
# File 'lib/List.rb', line 36

def dev_value
  return @value
end

#mod_ant(ant) ⇒ Object

Metodo para cambiar el puntero al anterior de un nodo



56
57
58
# File 'lib/List.rb', line 56

def mod_ant(ant)
  @ant = ant
end

#mod_sig(sig) ⇒ Object

Metodo para cambiar el puntero a siguiente de un nodo



51
52
53
# File 'lib/List.rb', line 51

def mod_sig(sig)
  @sig = sig
end

#to_sObject

Metodo para mostrar por pantalla un nodo



27
28
29
30
31
32
33
# File 'lib/List.rb', line 27

def to_s
  if @sig == nil && @ant == nil
    "#{@value} " 
  else 
    "#{@value} <-> " 
  end
end