Class Index [+]

Quicksearch

Sequel::Plugins::Tree::InstanceMethods

Public Instance Methods

ancestors() click to toggle source

Returns list of ancestors, starting from parent until root.

  subchild1.ancestors # => [child1, root]
    # File lib/sequel/plugins/tree.rb, line 86
86:         def ancestors
87:           node, nodes = self, []
88:           nodes << node = node.parent while node.parent
89:           nodes
90:         end
descendants() click to toggle source

Returns list of ancestors, starting from parent until root.

  subchild1.ancestors # => [child1, root]
    # File lib/sequel/plugins/tree.rb, line 95
95:         def descendants
96:           nodes = children.dup
97:           nodes.each{|child| nodes.concat(child.descendants)}
98:           nodes 
99:         end
root() click to toggle source

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

     # File lib/sequel/plugins/tree.rb, line 103
103:         def root
104:           ancestors.last || self
105:         end
root?() click to toggle source

Returns true if this is a root node, false otherwise.

     # File lib/sequel/plugins/tree.rb, line 108
108:         def root?
109:           !new? && self[model.parent_column].nil?
110:         end
self_and_siblings() click to toggle source

Returns all siblings and a reference to the current node.

  subchild1.self_and_siblings # => [subchild1, subchild2]
     # File lib/sequel/plugins/tree.rb, line 115
115:         def self_and_siblings
116:           parent ? parent.children : model.roots
117:         end
siblings() click to toggle source

Returns all siblings of the current node.

  subchild1.siblings # => [subchild2]
     # File lib/sequel/plugins/tree.rb, line 122
122:         def siblings
123:           self_and_siblings - [self]
124:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.