class XMP

#=> “a good day”
ctx.eval ‘today # is what?’
#==>“a good day”
#=> today = “a good day”
x.puts
x = XMP.new ctx
ctx = binding
expressions in the given binding:
You can also create an XMP object, with an optional binding to print
#==>42
#=> baz = 42
#==>“bar”
#=> foo = “bar”
END
baz = 42
foo = “bar”
xmp <<END
Now, you can take advantage of the Object#xmp convenience method.
require ‘irb/xmp’
In order to use this library, you must first require it:
expression as it runs.
It’s much like the standard library PrettyPrint, that shows the value of each
An example printer for irb.

def initialize(bind = nil)

full detail.
This uses the +:XMP+ prompt mode, see IRB@Customizing+the+IRB+Prompt for

creating the workspace. See WorkSpace.new for more information.
The top-level binding or, optional +bind+ parameter will be used when

Creates a new XMP object.
def initialize(bind = nil)
  IRB.init_config(nil)
  IRB.conf[:PROMPT_MODE] = :XMP
  bind = IRB::Frame.top(1) unless bind
  ws = IRB::WorkSpace.new(bind)
  @io = StringInputMethod.new
  @irb = IRB::Irb.new(ws, @io)
  @irb.context.ignore_sigint = false
  IRB.conf[:MAIN_CONTEXT] = @irb.context
end

def puts(exps)

# ==>"bar"
# => foo = "bar"
x.puts 'foo = "bar"'
# ==>{:a=>1, :b=>2, :c=>3}
#=> {:a => 1, :b => 2, :c => 3}
x.puts '{:a => 1, :b => 2, :c => 3}'

x = XMP.new
require 'irb/xmp'

Evaluates the given +exps+, for example:
def puts(exps)
  @io.puts exps
  if @irb.context.ignore_sigint
    begin
      trap_proc_b = trap("SIGINT"){@irb.signal_handle}
      catch(:IRB_EXIT) do
        @irb.eval_input
      end
    ensure
      trap("SIGINT", trap_proc_b)
    end
  else
    catch(:IRB_EXIT) do
      @irb.eval_input
    end
  end
end