    # File lib/facets/core/module/instance_methods.rb, line 40
      def instance_methods(*args)

        # for backward compatibility
        args << true if args.empty?
        case args[0]
        when TrueClass
          args.shift
          args << :ancestors
          args << :local
        when FalseClass
          args.shift
          args << :local
        end

        # default public, local
        args |= [:public] unless [:publix,:private,:protected,:all].any?{ |a| args.include?(a) }
        args |= [:ancestors,:local] unless [:ancestors,:inherited,:local,:all].any?{ |a| args.include?(a) }

        raise ArgumentError if args.any?{ |a| ! METHOD_TYPES.include?(a) }

        pos, neg = args.partition { |s| ! s.not? }

        m = []

        pos.each do |n|
          case n
          when :inherited, :ancestors
            m |= ( public_instance_methods( true ) - public_instance_methods( false ) )       if pos.include?(:public)
            m |= ( private_instance_methods( true ) - private_instance_methods( false ) )     if pos.include?(:private)
            m |= ( protected_instance_methods( true ) - protected_instance_methods( false ) ) if pos.include?(:protected)
          when :local
            m |= public_instance_methods( false )    if pos.include?(:public)
            m |= private_instance_methods( false )   if pos.include?(:private)
            m |= protected_instance_methods( false ) if pos.include?(:protected)
          when :all
            m |= public_instance_methods( true )
            m |= private_instance_methods( true )
            m |= protected_instance_methods( true )
          end
        end

        neg.each do |n|
          case n
          when :public
            m -= public_instance_methods( true )
          when :private
            m -= private_instance_methods( true )
          when :protected
            m -= protected_instance_methods( true )
          when :inherited, :ancestors
            m -= ( public_instance_methods( true ) - public_instance_methods( false ) )
            m -= ( private_instance_methods( true ) - private_instance_methods( false ) )
            m -= ( protected_instance_methods( true ) - protected_instance_methods( false ) )
          when :local
            m -= public_instance_methods( false )
            m -= private_instance_methods( false )
            m -= protected_instance_methods( false )
          end
        end

        m.sort
      end