#--
# Credit goes to Gavin Sinclair.
#++
module Enumerable

  # Enumerable#none? is the logical opposite of the builtin method
  # Enumerable#any?.  It returns +true+ if and only if _none_ of
  # the elements in the collection satisfy the predicate.
  #
  # If no predicate is provided, Enumerable#none? returns +true+
  # if and only if _none_ of the elements have a true value
  # (i.e. not +nil+ or +false+).
  #
  #   [].none?                      # true
  #   [nil].none?                   # true
  #   [5,8,9].none?                 # false
  #   (1...10).none? { |n| n < 0 }  # true
  #   (1...10).none? { |n| n > 0 }  # false
  #
  def none?  # :yield: e
    if block_given?
      not self.any? { |e| yield e }
    else
      not self.any?
    end
  end

end


#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCEnumerable < Test::Unit::TestCase

    def test_none?
      a = [nil, nil]
      assert( a.none? )
      a = [false, false]
      assert( a.none? )
      a = [true, false]
      assert( ! a.none? )
      a = [nil, 1]
      assert( ! a.none? )
    end

  end

=end
