inspect_mode=(opt)
public
Show source
def inspect_mode=(opt)
if i = Inspector::INSPECTORS[opt]
@inspect_mode = opt
@inspect_method = i
i.init
else
case opt
when nil
if Inspector.keys_with_inspector(Inspector::INSPECTORS[true]).include?(@inspect_mode)
self.inspect_mode = false
elsif Inspector.keys_with_inspector(Inspector::INSPECTORS[false]).include?(@inspect_mode)
self.inspect_mode = true
else
puts "Can't switch inspect mode."
return
end
when /^\s*\{.*\}\s*$/
begin
inspector = eval "proc#{opt}"
rescue Exception
puts "Can't switch inspect mode(#{opt})."
return
end
self.inspect_mode = inspector
when Proc
self.inspect_mode = IRB::Inspector(opt)
when Inspector
prefix = "usr%d"
i = 1
while Inspector::INSPECTORS[format(prefix, i)]; i += 1; end
@inspect_mode = format(prefix, i)
@inspect_method = opt
Inspector.def_inspector(format(prefix, i), @inspect_method)
else
puts "Can't switch inspect mode(#{opt})."
return
end
end
print "Switch to#{unless @inspect_mode; ' non';end} inspect mode.\n" if verbose?
@inspect_mode
end