Class: SpaghettiStack::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, parent = nil) ⇒ Node

Returns a new instance of Node.



10
11
12
13
# File 'lib/spaghetti_stack.rb', line 10

def initialize(data, parent = nil)
  @data = data
  @parent = parent
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



8
9
10
# File 'lib/spaghetti_stack.rb', line 8

def data
  @data
end

#parentObject (readonly)

Returns the value of attribute parent.



8
9
10
# File 'lib/spaghetti_stack.rb', line 8

def parent
  @parent
end

Instance Method Details

#update(data) ⇒ Object



15
16
17
18
# File 'lib/spaghetti_stack.rb', line 15

def update(data)
  return @data if @data.frozen?
  @data = data
end