Class: Node

Inherits:
Object
  • Object
show all
Defined in:
lib/nutrientes/list.rb

Overview

Class Node Defines the container of each element of the list

Constant Summary collapse

@@estructura =
Struct.new(:value, :next_, :prev_)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(val) ⇒ Node

Initialization of a node

Parameters:

  • val (Object)

    Value to store at the node



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

def initialize(val) 
    @nodo = @@estructura.new(val, nil, nil)
end

Instance Attribute Details

#nodoObject (readonly)

Returns the value of attribute nodo.



14
15
16
# File 'lib/nutrientes/list.rb', line 14

def nodo
  @nodo
end

#r nodo(nodo) ⇒ Object

Class Node Defines the container of each element of the list



12
13
14
15
16
17
18
19
20
21
# File 'lib/nutrientes/list.rb', line 12

class Node
    @@estructura = Struct.new(:value, :next_, :prev_)
    attr_reader :nodo
    
    # Initialization of a node
    # @param val [Object] Value to store at the node
    def initialize(val) 
        @nodo = @@estructura.new(val, nil, nil)
    end
end