new(irb, workspace = nil, input_method = nil, output_method = nil)
public
Show source
def initialize(irb, workspace = nil, input_method = nil, output_method = nil)
@irb = irb
if workspace
@workspace = workspace
else
@workspace = WorkSpace.new
end
@thread = Thread.current if defined? Thread
@ap_name = IRB.conf[:AP_NAME]
@rc = IRB.conf[:RC]
@load_modules = IRB.conf[:LOAD_MODULES]
@use_readline = IRB.conf[:USE_READLINE]
@verbose = IRB.conf[:VERBOSE]
@io = nil
self.inspect_mode = IRB.conf[:INSPECT_MODE]
self.math_mode = IRB.conf[:MATH_MODE] if IRB.conf[:MATH_MODE]
self.use_tracer = IRB.conf[:USE_TRACER] if IRB.conf[:USE_TRACER]
self.use_loader = IRB.conf[:USE_LOADER] if IRB.conf[:USE_LOADER]
self.eval_history = IRB.conf[:EVAL_HISTORY] if IRB.conf[:EVAL_HISTORY]
@ignore_sigint = IRB.conf[:IGNORE_SIGINT]
@ignore_eof = IRB.conf[:IGNORE_EOF]
@back_trace_limit = IRB.conf[:BACK_TRACE_LIMIT]
self.prompt_mode = IRB.conf[:PROMPT_MODE]
if IRB.conf[:SINGLE_IRB] or !defined?(JobManager)
@irb_name = IRB.conf[:IRB_NAME]
else
@irb_name = "irb#"+IRB.JobManager.n_jobs.to_s
end
@irb_path = "(" + @irb_name + ")"
case input_method
when nil
case use_readline?
when nil
if (defined?(ReadlineInputMethod) && STDIN.tty? &&
IRB.conf[:PROMPT_MODE] != :INF_RUBY)
@io = ReadlineInputMethod.new
else
@io = StdioInputMethod.new
end
when false
@io = StdioInputMethod.new
when true
if defined?(ReadlineInputMethod)
@io = ReadlineInputMethod.new
else
@io = StdioInputMethod.new
end
end
when String
@io = FileInputMethod.new(input_method)
@irb_name = File.basename(input_method)
@irb_path = input_method
else
@io = input_method
end
self.save_history = IRB.conf[:SAVE_HISTORY] if IRB.conf[:SAVE_HISTORY]
if output_method
@output_method = output_method
else
@output_method = StdioOutputMethod.new
end
@echo = IRB.conf[:ECHO]
if @echo.nil?
@echo = true
end
@debug_level = IRB.conf[:DEBUG_LEVEL]
end