Imported File#ftype spec from rubyspecs.
[rbx.git] / lib / irb / ext / workspaces.rb
blob913046d79a4508a40fe3f71be253a3b4a608962e
2 #   push-ws.rb - 
3 #       $Release Version: 0.9.5$
4 #       $Revision: 11708 $
5 #       $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
6 #       by Keiju ISHITSUKA(keiju@ruby-lang.org)
8 # --
10 #   
13 module IRB
14   class Context
16     def irb_level
17       workspace_stack.size
18     end
20     def workspaces
21       if defined? @workspaces
22         @workspaces
23       else
24         @workspaces = []
25       end
26     end
28     def push_workspace(*_main)
29       if _main.empty?
30         if workspaces.empty?
31           print "No other workspace\n"
32           return nil
33         end
34         ws = workspaces.pop
35         workspaces.push @workspace
36         @workspace = ws
37         return workspaces
38       end
40       workspaces.push @workspace
41       @workspace = WorkSpace.new(@workspace.binding, _main[0])
42       if !(class<<main;ancestors;end).include?(ExtendCommandBundle)
43         main.extend ExtendCommandBundle
44       end
45     end
47     def pop_workspace
48       if workspaces.empty?
49         print "workspace stack empty\n"
50         return
51       end
52       @workspace = workspaces.pop
53     end
54   end
55 end