Module: ExtendedNestedSet::InstanceMethods
- Defined in:
- lib/extended_nested_set/instance_methods.rb
Instance Method Summary collapse
- #is_first_of_siblings?(parent = nil) ⇒ Boolean
- #is_last_of_siblings?(parent = nil) ⇒ Boolean
- #move_higher ⇒ Object
- #move_lower ⇒ Object
- #move_to_bottom ⇒ Object
- #move_to_top ⇒ Object
Instance Method Details
#is_first_of_siblings?(parent = nil) ⇒ Boolean
4 5 6 7 8 9 10 |
# File 'lib/extended_nested_set/instance_methods.rb', line 4 def is_first_of_siblings?(parent = nil) if parent parent.lft == self.lft - 1 else left_sibling.nil? end end |
#is_last_of_siblings?(parent = nil) ⇒ Boolean
12 13 14 15 16 17 18 |
# File 'lib/extended_nested_set/instance_methods.rb', line 12 def is_last_of_siblings?(parent = nil) if parent parent.rgt == self.rgt + 1 else right_sibling.nil? end end |
#move_higher ⇒ Object
24 25 26 |
# File 'lib/extended_nested_set/instance_methods.rb', line 24 def move_higher move_to_left_of left_sibling unless is_first_of_siblings? end |
#move_lower ⇒ Object
20 21 22 |
# File 'lib/extended_nested_set/instance_methods.rb', line 20 def move_lower move_to_right_of(right_sibling) unless is_last_of_siblings? end |
#move_to_bottom ⇒ Object
28 29 30 |
# File 'lib/extended_nested_set/instance_methods.rb', line 28 def move_to_bottom move_to_right_of siblings.last unless is_last_of_siblings? end |
#move_to_top ⇒ Object
32 33 34 |
# File 'lib/extended_nested_set/instance_methods.rb', line 32 def move_to_top move_to_left_of siblings.first unless is_first_of_siblings? end |