class IRB::JobManager

def search(key)

Raises a NoSuchJob exception if no job can be found with the given +key+.

given +key+.
Otherwise returns the irb session with the same top-level binding as the

+key+ using Object#=== on the jobs Array.
If given an instance of Thread, it will return the associated thread

associated with +key+.
When an instance of Irb is given, it will return the irb session

If given an Integer, it will return the +key+ index for the jobs Array.

Returns the associated job for the given +key+.
def search(key)
  job = case key
        when Integer
          @jobs[key]
        when Irb
          @jobs.find{|k, v| v.equal?(key)}
        when Thread
          @jobs.assoc(key)
        else
          @jobs.find{|k, v| v.context.main.equal?(key)}
        end
  fail NoSuchJob, key if job.nil?
  job
end