Class: Pry::REPL

Inherits:
Object show all
Extended by:
Forwardable
Defined in:
lib/pry/repl.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pry, options = {}) ⇒ REPL

Create an instance of Pry::REPL wrapping the given Pry.

Parameters:

  • pry (Pry)

    The instance of Pry that this Pry::REPL will control.

  • options (Hash) (defaults to: {})

    Options for this Pry::REPL instance.

Options Hash (options):

  • :target (Object)

    The initial target of the session.


22
23
24
25
26
27
28
29
# File 'lib/pry/repl.rb', line 22

def initialize(pry, options = {})
  @pry    = pry
  @indent = Pry::Indent.new

  if options[:target]
    @pry.push_binding options[:target]
  end
end

Instance Attribute Details

#pryPry

Returns The instance of Pry that the user is controlling.

Returns:

  • (Pry)

    The instance of Pry that the user is controlling.


9
10
11
# File 'lib/pry/repl.rb', line 9

def pry
  @pry
end

Class Method Details

.start(options) ⇒ Object

Instantiate a new Pry instance with the given options, then start a Pry::REPL instance wrapping it.

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):


14
15
16
# File 'lib/pry/repl.rb', line 14

def self.start(options)
  new(Pry.new(options)).start
end

Instance Method Details

#startObject?

Start the read-eval-print loop.

Returns:

  • (Object?)

    If the session throws `:breakout`, return the value thrown with it.

Raises:

  • (Exception)

    If the session throws `:raise_up`, raise the exception thrown with it.


36
37
38
39
40
41
# File 'lib/pry/repl.rb', line 36

def start
  prologue
  Pry::InputLock.for(:all).with_ownership { repl }
ensure
  epilogue
end