Class: Pry::Command::Edit::ExceptionPatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/pry/commands/edit/exception_patcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_pry_, state, exception_file_and_line) ⇒ ExceptionPatcher

Returns a new instance of ExceptionPatcher



8
9
10
11
12
# File 'lib/pry/commands/edit/exception_patcher.rb', line 8

def initialize(_pry_, state, exception_file_and_line)
  @_pry_ = _pry_
  @state = state
  @file_and_line = exception_file_and_line
end

Instance Attribute Details

#_pry_Object

Returns the value of attribute pry



4
5
6
# File 'lib/pry/commands/edit/exception_patcher.rb', line 4

def _pry_
  @_pry_
end

#file_and_lineObject

Returns the value of attribute file_and_line



6
7
8
# File 'lib/pry/commands/edit/exception_patcher.rb', line 6

def file_and_line
  @file_and_line
end

#stateObject

Returns the value of attribute state



5
6
7
# File 'lib/pry/commands/edit/exception_patcher.rb', line 5

def state
  @state
end

Instance Method Details

#perform_patchObject

perform the patch



15
16
17
18
19
20
21
22
# File 'lib/pry/commands/edit/exception_patcher.rb', line 15

def perform_patch
  file_name, _ = file_and_line
  lines = state.dynamical_ex_file || File.read(file_name)

  source = Pry::Editor.new(_pry_).edit_tempfile_with_content(lines)
  _pry_.evaluate_ruby source
  state.dynamical_ex_file = source.split("\n")
end