Module | Sequel::Plugins::Tree::InstanceMethods
In: | lib/sequel/plugins/tree.rb

### Methods

ancestors descendants root self_and_siblings siblings

### Public Instance methods

ancestors()

Returns list of ancestors, starting from parent until root.

      subchild1.ancestors # => [child1, root]

[Source]

        # File lib/sequel/plugins/tree.rb, line 81
    81:         def ancestors
    82:           node, nodes = self, []
    83:           nodes << node = node.parent while node.parent
    84:           nodes
    85:         end

descendants()

Returns list of ancestors, starting from parent until root.

      subchild1.ancestors # => [child1, root]

[Source]

        # File lib/sequel/plugins/tree.rb, line 90
    90:         def descendants
    91:           nodes = self.children.dup
    92:           nodes.each{|child| nodes.concat(child.descendants)}
    93:           nodes
    94:         end

root()

Returns the root node of the tree that this node descends from This node is returned if it is a root node itself.

[Source]

         # File lib/sequel/plugins/tree.rb, line 98
     98:         def root
     99:           ancestors.last || self
    100:         end

self_and_siblings()

Returns all siblings and a reference to the current node.

      subchild1.self_and_siblings # => [subchild1, subchild2]

[Source]

         # File lib/sequel/plugins/tree.rb, line 105
    105:         def self_and_siblings
    106:           parent ? parent.children : model.roots
    107:         end

siblings()

Returns all siblings of the current node.

      subchild1.siblings # => [subchild2]

[Source]

         # File lib/sequel/plugins/tree.rb, line 112
    112:         def siblings
    113:           self_and_siblings - [self]
    114:         end

[Validate]