class Node
Attributes
children[RW]
id[R]
node[RW]
parent_id[R]
Public Class Methods
new(data_hash, id, parent_id)
click to toggle source
# File lib/pomona/node.rb, line 7 def initialize(data_hash, id, parent_id) @id = id node_data = { id: @id, children: [] } @node = data_hash.merge(node_data) @children = @node[:children] @parent_id = parent_id end
Public Instance Methods
has_children?()
click to toggle source
# File lib/pomona/node.rb, line 15 def has_children? children.any? end
has_grandchildren?()
click to toggle source
# File lib/pomona/node.rb, line 19 def has_grandchildren? if has_children? children.select { |child| child.has_children? }.any? else false end end