Sha256: 0e25a5639613f4770dab17ee857be88b78b07447fb3fc2e63dbb6d00091575f6

Contents?: true

Size: 630 Bytes

Versions: 1

Compression:

Stored size: 630 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

1 entries across 1 versions & 1 rubygems

Version Path
rd_awesome_nested_set-1.4.4 lib/awesome_nested_set/descendants.rb