I would do a module and then mix that in to any of your required 
classes.  The module has one public method, 'proximity' that looks at 
the class of 'self' and of the other object, and then decides what to do 
accordingly.  The various behaviours for comparing different classes can 
be expressed through various private methods.  eg

#save in a file called proximity.rb
module Proximity
  def proximity(other)
    case [self.class, other.class]
      when [Array, Array]
        return array_array_proximity(self, other)
      when [Array, String] || [String, Array]
        return string_array_proximity
      #etc
      else
        return false #or raise
      end
    end
  end

private
  def array_array_proximity(arg1, arg2)
    #your logic here
  end

  def string_array_proximity(arg1, arg2)
    #your logic here
  end

  #etc
end

Now you can include this module into the various classes - somewhere in 
your initialisation process you can do

require 'proximity'

class Array
  include Proximity
end

class String
  include Proximity
end

etc
-- 
Posted via http://www.ruby-forum.com/.