Method: ActiveComponent::Base#nodeDepth

Defined in:
lib/active_component/base.rb

#nodeDepthNumber Also known as: level

Returns depth of the receiver node in its tree. Depth of a node is defined as:

Depth

Length of the node’s path to its root. Depth of a root node is zero.

‘level’ is an alias for this method.

Returns:

  • (Number)

    Depth of this node.



853
854
855
856
# File 'lib/active_component/base.rb', line 853

def nodeDepth
  return 0 if isRoot?
  1 + parent.nodeDepth
end