Class: IRB::Kit::Helpers::EditSource
- Inherits:
-
HelperMethod::Base
- Object
- HelperMethod::Base
- IRB::Kit::Helpers::EditSource
- Defined in:
- lib/irb/kit/helpers/edit_source.rb
Overview
Edits the source code of a constant or method.
Constant Summary collapse
- MONIKER =
:esource
Instance Method Summary collapse
- #execute(*arguments) ⇒ Object
-
#initialize(constant_handler: Handlers::ConstantEditor.new, method_handler: Handlers::MethodEditor.new) ⇒ EditSource
constructor
A new instance of EditSource.
Constructor Details
#initialize(constant_handler: Handlers::ConstantEditor.new, method_handler: Handlers::MethodEditor.new) ⇒ EditSource
Returns a new instance of EditSource.
14 15 16 17 18 19 |
# File 'lib/irb/kit/helpers/edit_source.rb', line 14 def initialize constant_handler: Handlers::ConstantEditor.new, method_handler: Handlers::MethodEditor.new super() @constant_handler = constant_handler @method_handler = method_handler end |
Instance Method Details
#execute(*arguments) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/irb/kit/helpers/edit_source.rb', line 21 def execute(*arguments) case arguments in [name] then puts constant_handler.call(name) in [object, name] then puts method_handler.call(object, name) else puts "ERROR: Invalid constant or method for arguments: #{arguments.inspect}." end end |