123456789_123456789_123456789_123456789_123456789_

Class: IRB::Command::CD

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Base
Instance Chain:
self, Base
Inherits: IRB::Command::Base
Defined in: lib/irb/command/cd.rb

Class Method Summary

Instance Attribute Summary

Base - Inherited

Instance Method Summary

Constructor Details

This class inherits a constructor from IRB::Command::Base

Instance Method Details

#execute(arg)

[ GitHub ]

  
# 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