Class: SpaghettiStack::Node
- Inherits:
-
Object
- Object
- SpaghettiStack::Node
- Defined in:
- lib/spaghetti_stack.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#initialize(data, parent = nil) ⇒ Node
constructor
A new instance of Node.
- #update(data) ⇒ Object
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
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/spaghetti_stack.rb', line 8 def data @data end |
#parent ⇒ Object (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 |