Sha256: e16c164bea0c31a42b0c7c6fef5f9fdfdf6b25bbbdfea939d56ffcfdf2a350e6

Contents?: true

Size: 1.08 KB

Versions: 9

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true
#
#   push-ws.rb -
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
#

module IRB # :nodoc:
  class Context
    # Creates a new workspace with the given object or binding, and appends it
    # onto the current #workspaces stack.
    #
    # See IRB::Context#change_workspace and IRB::WorkSpace.new for more
    # information.
    def push_workspace(*_main)
      if _main.empty?
        if @workspace_stack.size > 1
          # swap the top two workspaces
          previous_workspace, current_workspace = @workspace_stack.pop(2)
          @workspace_stack.push current_workspace, previous_workspace
        end
      else
        new_workspace = WorkSpace.new(workspace.binding, _main[0])
        @workspace_stack.push new_workspace
        new_workspace.load_helper_methods_to_main
      end
    end

    # Removes the last element from the current #workspaces stack and returns
    # it, or +nil+ if the current workspace stack is empty.
    #
    # Also, see #push_workspace.
    def pop_workspace
      @workspace_stack.pop if @workspace_stack.size > 1
    end
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/irb-1.14.0/lib/irb/ext/workspaces.rb
irb-1.14.3 lib/irb/ext/workspaces.rb
irb-1.14.2 lib/irb/ext/workspaces.rb
irb-1.14.1 lib/irb/ext/workspaces.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/irb-1.13.2/lib/irb/ext/workspaces.rb
irb-1.14.0 lib/irb/ext/workspaces.rb
irb-1.13.2 lib/irb/ext/workspaces.rb
irb-1.13.1 lib/irb/ext/workspaces.rb
irb-1.13.0 lib/irb/ext/workspaces.rb