Method: ActiveComponent::Base#nodeHeight

Defined in:
lib/active_component/base.rb

#nodeHeightNumber

Returns height of the (sub)tree from the receiver node. Height of a node is defined as:

Height

Length of the longest downward path to a leaf from the node.

  • Height from a root node is height of the entire tree.

  • The height of a leaf node is zero.

Returns:

  • (Number)

    Height of the node.



841
842
843
844
# File 'lib/active_component/base.rb', line 841

def nodeHeight
  return 0 if isLeaf?
  1 + @children.collect { |child| child.nodeHeight }.max
end