# File irb/ext/multi-irb.rb, line 45
def main_irb
@jobs[0][1]
end
Extended maintenance of Ruby 1.9.3 ended on February 23, 2015. Read more
job management class
# File irb/ext/multi-irb.rb, line 86
def delete(key)
case key
when Integer
IRB.fail NoSuchJob, key unless @jobs[key]
@jobs[key] = nil
else
catch(:EXISTS) do
@jobs.each_index do
|i|
if @jobs[i] and (@jobs[i][0] == key ||
@jobs[i][1] == key ||
@jobs[i][1].context.main.equal?(key))
@jobs[i] = nil
throw :EXISTS
end
end
IRB.fail NoSuchJob, key
end
end
until assoc = @jobs.pop; end unless @jobs.empty?
@jobs.push assoc
end
# File irb/ext/multi-irb.rb, line 49
def insert(irb)
@jobs.push [Thread.current, irb]
end
# File irb/ext/multi-irb.rb, line 109
def inspect
ary = []
@jobs.each_index do
|i|
th, irb = @jobs[i]
next if th.nil?
if th.alive?
if th.stop?
t_status = "stop"
else
t_status = "running"
end
else
t_status = "exited"
end
ary.push format("#%d->%s on %s (%s: %s)",
i,
irb.context.irb_name,
irb.context.main,
th,
t_status)
end
ary.join("\n")
end
# File irb/ext/multi-irb.rb, line 36
def irb(key)
_, irb = search(key)
irb
end
# File irb/ext/multi-irb.rb, line 63
def kill(*keys)
for key in keys
th, _ = search(key)
IRB.fail IrbAlreadyDead unless th.alive?
th.exit
end
end
# File irb/ext/multi-irb.rb, line 41
def main_thread
@jobs[0][0]
end
# File irb/ext/multi-irb.rb, line 71
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
IRB.fail NoSuchJob, key if job.nil?
job
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.