Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Object#xmp

xmp(exps, bind = nil)

A convenience method that’s only available when the you require the IRB::XMP standard library.

Creates a new XMP object, using the given expressions as the exps parameter, and optional binding as bind or uses the top-level binding. Then evaluates the given expressions using the :XMP prompt mode.

For example:

Example
require 'irb/xmp'
ctx = binding
xmp 'foo = "bar"', ctx
#=> foo = "bar"
  #==>"bar"
ctx.eval 'foo'
#=> "bar"

See XMP.new for more information.

See also #to_yaml #to_s also in 3.4 · 3.3 · 3.1 · 3.0