Class: IRB::Kit::Handlers::MethodEditor

Inherits:
Abstract
  • Object
show all
Defined in:
lib/irb/kit/handlers/method_editor.rb

Overview

Handles editing of method source code.

Instance Method Summary collapse

Constructor Details

#initialize(editor: Editor.new) ⇒ MethodEditor

Returns a new instance of MethodEditor.



8
9
10
11
# File 'lib/irb/kit/handlers/method_editor.rb', line 8

def initialize(editor: Editor.new, **)
  @editor = editor
  super(**)
end

Instance Method Details

#call(object, name) ⇒ Object



13
14
15
16
17
# File 'lib/irb/kit/handlers/method_editor.rb', line 13

def call object, name
  editor.call(*object.method(name).source_location)
rescue NameError
  io.puts "ERROR: Undefined method `#{name.inspect}` for `#{object.inspect}`."
end