Class: Node
- Inherits:
-
Struct
- Object
- Struct
- Node
- 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
-
#ant ⇒ Object
Returns the value of attribute ant.
-
#sig ⇒ Object
Returns the value of attribute sig.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#dev_ant ⇒ Object
Funcion para obtener el puntero al anterior de un nodo.
-
#dev_sig ⇒ Object
Funcion para obtener el puntero a siguiente de un nodo.
-
#dev_value ⇒ Object
Funcion para obtener el valor de un nodo.
-
#initialize(value, sig, ant) ⇒ Node
constructor
Metodo para inicializar la clase.
-
#mod_ant(ant) ⇒ Object
Metodo para cambiar el puntero al anterior de un nodo.
-
#mod_sig(sig) ⇒ Object
Metodo para cambiar el puntero a siguiente de un nodo.
-
#to_s ⇒ Object
Metodo para mostrar por pantalla un nodo.
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
#ant ⇒ Object
Returns the value of attribute ant
18 19 20 |
# File 'lib/List.rb', line 18 def ant @ant end |
#sig ⇒ Object
Returns the value of attribute sig
18 19 20 |
# File 'lib/List.rb', line 18 def sig @sig end |
#value ⇒ Object
Returns the value of attribute value
18 19 20 |
# File 'lib/List.rb', line 18 def value @value end |
Instance Method Details
#dev_ant ⇒ Object
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_sig ⇒ Object
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_value ⇒ Object
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_s ⇒ Object
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 |