Module: IRB

Defined in:
lib/tins/xt/irb.rb

Overview

We extend the top level IRB module

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.examine(binding = TOPLEVEL_BINDING) ⇒ Object

Starts an interactive IRB session with the given binding context. This method creates a new IRB instance and evaluates input from it, allowing for interactive exploration of variables and objects.

Examples:

Start IRB with current context

examine

Examine specific binding

examine some_binding

Parameters:

  • binding (Binding, nil) (defaults to: TOPLEVEL_BINDING)

    The binding context to examine (defaults to TOPLEVEL_BINDING)



40
41
42
43
44
45
46
47
48
# File 'lib/tins/xt/irb.rb', line 40

def self.examine(binding = TOPLEVEL_BINDING)
  setup nil
  workspace = WorkSpace.new binding
  irb = Irb.new workspace
  @CONF[:MAIN_CONTEXT] = irb.context
  catch(:IRB_EXIT) { irb.eval_input }
rescue Interrupt
  exit
end

Instance Method Details

#examine(binding = TOPLEVEL_BINDING) ⇒ void

This method returns an undefined value.

Starts an interactive IRB session examining the current object and its context. This instance method provides a convenient way to debug objects without explicitly passing bindings.

Examples:

Examine the current object

my_object.examine

Examine a specific variable

data = [1, 2, 3]
data.examine  # Inspects just the 'data' variable

Parameters:

  • binding (Binding, nil) (defaults to: TOPLEVEL_BINDING)

    The binding context to examine (defaults to TOPLEVEL_BINDING)



63
64
65
# File 'lib/tins/xt/irb.rb', line 63

def examine(binding = TOPLEVEL_BINDING)
  IRB.examine(binding)
end