The attached patch gives you the ability to ask a child if it is a descendant of the passed in node. For example:
child.descendant_of?(root) # => true
child.descendant_of?(parent) # => true
child.descendant_of?(child) # => true
child.descendant_of?(cousin) # => false
child.descendant_of?(someone_elses_parent) # => false
child.descendant_of?(another_root_outside_this_set) # => false
It will return true if the child's left and right values are within the bounds of the passed in node's left and right values. A node is considered a descendant of itself (the bounds checking is inclusive).
Tests have been added. Please commit the patch. If any questions let us know,
- Ryan Fogle
- fogle at atomicobject dot com