Parent

Object

Constants

CLIPPED_PRINT

useful when playing with truly enormous objects

DEFAULT_CONTROL_D_HANDLER

Deal with the ^D key being pressed, different behaviour in different cases: 1) In an expression - behave like `!` command (clear input buffer) 2) At top-level session - behave like `exit command (break out of repl loop) 3) In a nested session - behave like `cd ..` (pop a binding)

DEFAULT_EXCEPTION_HANDLER

Will only show the first line of the backtrace

DEFAULT_EXCEPTION_WHITELIST

Don't catch these exceptions

DEFAULT_PROMPT

The default prompt; includes the target and nesting level

DEFAULT_SYSTEM
NAV_PROMPT

A prompt that includes the full object path as well as input/output (in and out) information. Good for navigation.

SHELL_PROMPT
SIMPLE_PRINT

may be convenient when working with enormous objects and pretty_print is too slow

SIMPLE_PROMPT

A simple prompt - doesn't display target or nesting level

Public Class Methods

__pry__() click to toggle source

Grab a copy of the TOPLEVEL_BINDING without any local variables. This binding has a default definee of Object, and new methods are private (just as in TOPLEVEL_BINDING).

# File lib/pry/pry_class.rb, line 391
def self.__pry__
  binding
end

Public Instance Methods

__binding__() click to toggle source

Return a binding object for the receiver.

The `self` of the binding is set to the current object, and it contains no local variables.

The default definee (yugui.jp/articles/846) is set such that:

  • If `self` is a class or module, then new methods created in the binding will be defined in that class or module (as in `class Foo; end`).

  • If `self` is a normal object, then new methods created in the binding will be defined on its singleton class (as in `class << self; end`).

  • If `self` doesn't have a real singleton class (i.e. it is a Fixnum, Float, Symbol, nil, true, or false), then new methods will be created on the object's class (as in `self.class.class_eval{ }`)

Newly created constants, including classes and modules, will also be added to the default definee.

@return [Binding]

# File lib/pry/core_extensions.rb, line 47
def __binding__
  # When you're cd'd into a class, methods you define should be added to it.
  if is_a?(Module)
    # class_eval sets both self and the default definee to this class.
    return class_eval "binding"
  end

  unless respond_to?(:__pry__)
    binding_impl_method = [        # Get a binding with 'self' set to self, and no locals.        #        # The default definee is determined by the context in which the        # definition is eval'd.        #        # Please don't call this method directly, see {__binding__}.        #        # @return [Binding]        def __pry__          binding        end, __FILE__, __LINE__ + 1]

    # The easiest way to check whether an object has a working singleton class
    # is to try and define a method on it. (just checking for the presence of
    # the singleton class gives false positives for `true` and `false`).
    # __pry__ is just the closest method we have to hand, and using
    # it has the nice property that we can memoize this check.
    begin
      # instance_eval sets the default definee to the object's singleton class
      instance_eval(*binding_impl_method)

    # If we can't define methods on the Object's singleton_class. Then we fall
    # back to setting the default definee to be the Object's class. That seems
    # nicer than having a REPL in which you can't define methods.
    rescue TypeError
      # class_eval sets the default definee to self.class
      self.class.class_eval(*binding_impl_method)
    end
  end

  __pry__
end
pry(object=nil, hash={}) click to toggle source

Start a Pry REPL on self.

If `self` is a Binding then that will be used to evaluate expressions; otherwise a new binding will be created.

@param [Object] object the object or binding to pry

(__deprecated__, use `object.pry`)

@param [Hash] hash the options hash @example With a binding

binding.pry

@example On any object

"dummy".pry

@example With options

def my_method
  binding.pry :quiet => true
end
my_method()

@see Pry.start

# File lib/pry/core_extensions.rb, line 20
def pry(object=nil, hash={})
  if object.nil? || Hash === object
    Pry.start(self, object || {})
  else
    Pry.start(object, hash)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.