2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2002-07-09 07:17:17 -04:00
|
|
|
#
|
2009-03-05 22:56:38 -05:00
|
|
|
# irb/ext/cb.rb -
|
2009-07-07 07:36:20 -04:00
|
|
|
# $Release Version: 0.9.6$
|
2002-07-09 07:17:17 -04:00
|
|
|
# $Revision$
|
2005-04-13 11:27:09 -04:00
|
|
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
2002-07-09 07:17:17 -04:00
|
|
|
#
|
|
|
|
# --
|
|
|
|
#
|
2009-03-05 22:56:38 -05:00
|
|
|
#
|
2002-07-09 07:17:17 -04:00
|
|
|
#
|
|
|
|
|
2012-12-13 00:22:30 -05:00
|
|
|
module IRB # :nodoc:
|
2002-07-09 07:17:17 -04:00
|
|
|
class Context
|
|
|
|
|
2012-12-21 00:45:50 -05:00
|
|
|
# Inherited from +TOPLEVEL_BINDING+.
|
2002-07-09 07:17:17 -04:00
|
|
|
def home_workspace
|
|
|
|
if defined? @home_workspace
|
2014-08-08 21:36:49 -04:00
|
|
|
@home_workspace
|
2002-07-09 07:17:17 -04:00
|
|
|
else
|
2014-08-08 21:36:49 -04:00
|
|
|
@home_workspace = @workspace
|
2002-07-09 07:17:17 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-13 00:22:30 -05:00
|
|
|
# Changes the current workspace to given object or binding.
|
|
|
|
#
|
|
|
|
# If the optional argument is omitted, the workspace will be
|
|
|
|
# #home_workspace which is inherited from +TOPLEVEL_BINDING+ or the main
|
|
|
|
# object, <code>IRB.conf[:MAIN_CONTEXT]</code> when irb was initialized.
|
|
|
|
#
|
|
|
|
# See IRB::WorkSpace.new for more information.
|
2002-07-09 07:17:17 -04:00
|
|
|
def change_workspace(*_main)
|
|
|
|
if _main.empty?
|
2014-08-08 21:36:49 -04:00
|
|
|
@workspace = home_workspace
|
|
|
|
return main
|
2002-07-09 07:17:17 -04:00
|
|
|
end
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2002-07-09 07:17:17 -04:00
|
|
|
@workspace = WorkSpace.new(_main[0])
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2002-07-09 07:17:17 -04:00
|
|
|
if !(class<<main;ancestors;end).include?(ExtendCommandBundle)
|
2014-08-08 21:36:49 -04:00
|
|
|
main.extend ExtendCommandBundle
|
2002-07-09 07:17:17 -04:00
|
|
|
end
|
|
|
|
end
|
2008-12-18 02:54:50 -05:00
|
|
|
end
|
2002-07-09 07:17:17 -04:00
|
|
|
end
|