Sha256: b9369b25cca4430a3fa2f1028393148d79bed8e0fa6d9dc5170432b67b3a6aaa

Contents?: true

Size: 571 Bytes

Versions: 5

Compression:

Stored size: 571 Bytes

Contents

module Sunrise
  module NestedSet
    module Descendants
      # Returns the number of nested children of this object.
      def descendants_count
        return (right - left - 1)/2
      end
      
      # Check if has descendants
      def has_descendants?
        !descendants_count.zero?
      end

      # Move node up or down (sort)
      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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sunrise-core-0.2.2 lib/sunrise/nested_set/descendants.rb
sunrise-core-0.2.1 lib/sunrise/nested_set/descendants.rb
sunrise-core-0.2.0 lib/sunrise/nested_set/descendants.rb
sunrise-core-0.1.5 lib/sunrise/nested_set/descendants.rb
sunrise-core-0.1.4 lib/sunrise/nested_set/descendants.rb