Class: TreeBranch::SimpleNode

Inherits:
Node
  • Object
show all
Defined in:
lib/tree_branch/simple_node.rb

Overview

A basic subclass of Node that makes the data element a deterministic and comparable OpenStruct object.

Instance Attribute Summary

Attributes inherited from Node

#children, #data

Instance Method Summary collapse

Methods inherited from Node

#==, #add, #eql?, #to_s

Constructor Details

#initialize(data: {}, children: []) ⇒ SimpleNode

Returns a new instance of SimpleNode.



16
17
18
19
# File 'lib/tree_branch/simple_node.rb', line 16

def initialize(data: {}, children: [])
  @data     = OpenStruct.new(data)
  @children = self.class.array(children)
end