Method: SimpleTree::InstanceMethods#ancestors
- Defined in:
- lib/simple_tree.rb
#ancestors ⇒ Object
Returns list of ancestors, starting from parent until root.
subchild1.ancestors # => [child1, root]
24 25 26 27 28 |
# File 'lib/simple_tree.rb', line 24 def ancestors node, nodes = self,[] nodes << node = node.parent while node.parent nodes end |