Sha256: e68340b010b34a5797ca992d854012e73d27c1d68c22896bb2f91c407c7f5313

Contents?: true

Size: 604 Bytes

Versions: 18

Compression:

Stored size: 604 Bytes

Contents

# encoding: utf-8
module CollectiveIdea #:nodoc:
  module Acts #:nodoc:
    module NestedSet #:nodoc:
      module Descendants
        # Returns the number of nested children of this object.
        def descendants_count
          return (right - left - 1)/2
        end

        def has_descendants?
          !descendants_count.zero?
        end

        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
end

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
nested_set-1.7.1 lib/nested_set/descendants.rb
nested_set-1.7.0 lib/nested_set/descendants.rb
nested_set-1.6.8 lib/nested_set/descendants.rb
nested_set-1.6.7 lib/nested_set/descendants.rb
nested_set-1.6.6 lib/nested_set/descendants.rb
nested_set-1.6.5 lib/nested_set/descendants.rb
nested_set-1.6.4 lib/nested_set/descendants.rb
nested_set-1.6.3 lib/nested_set/descendants.rb
nested_set-1.6.2 lib/nested_set/descendants.rb
nested_set-1.6.1 lib/nested_set/descendants.rb
nested_set-1.6.0 lib/nested_set/descendants.rb
nested_set-1.5.4 lib/nested_set/descendants.rb
nested_set-1.5.3 lib/nested_set/descendants.rb
nested_set-1.5.2 lib/nested_set/descendants.rb
nested_set-1.5.1 lib/nested_set/descendants.rb
nested_set-1.5.0 lib/nested_set/descendants.rb
moretea-awesome_nested_set-1.4.3.1 lib/awesome_nested_set/descendants.rb
be9-awesome_nested_set-1.4.3 lib/awesome_nested_set/descendants.rb