class IRB::Command::CD

Public Instance Methods

execute (arg)
# File lib/irb/command/cd.rb, line 29
def execute(arg)
  case arg
  when ".."
    irb_context.pop_workspace
  when ""
    # TODO: decide what workspace commands should be kept, and underlying APIs should look like,
    # and perhaps add a new API to clear the workspace stack.
    prev_workspace = irb_context.pop_workspace
    while prev_workspace
      prev_workspace = irb_context.pop_workspace
    end
  else
    begin
      obj = eval(arg, irb_context.workspace.binding)
      irb_context.push_workspace(obj)
    rescue StandardError => e
      warn "Error: #{e}"
    end
  end
end