Module: CollectiveIdea::Acts::NestedSet::Descendants
- Defined in:
- lib/awesome_nested_set/descendants.rb
Instance Method Summary collapse
-
#descendants_count ⇒ Object
Returns the number of nested children of this object.
- #has_descendants? ⇒ Boolean
- #move_by_direction(ditection) ⇒ Object
Instance Method Details
#descendants_count ⇒ Object
Returns the number of nested children of this object.
7 8 9 |
# File 'lib/awesome_nested_set/descendants.rb', line 7 def descendants_count return (right - left - 1)/2 end |
#has_descendants? ⇒ Boolean
11 12 13 |
# File 'lib/awesome_nested_set/descendants.rb', line 11 def has_descendants? !descendants_count.zero? end |
#move_by_direction(ditection) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/awesome_nested_set/descendants.rb', line 15 def move_by_direction(ditection) return if ditection.blank? case ditection.to_sym when :up, :left then move_left when :down, :right then move_right end end |