Class: IRB::Kit::Helpers::ConstantSource

Inherits:
HelperMethod::Base
  • Object
show all
Defined in:
lib/irb/kit/helpers/constant_source.rb

Overview

Finds constant’s source location.

Constant Summary collapse

MONIKER =
:csource

Instance Method Summary collapse

Constructor Details

#initialize(object = Object) ⇒ ConstantSource

Returns a new instance of ConstantSource.



12
13
14
15
# File 'lib/irb/kit/helpers/constant_source.rb', line 12

def initialize object = Object
  super()
  @object = object
end

Instance Method Details

#execute(name) ⇒ Object



17
18
19
20
21
# File 'lib/irb/kit/helpers/constant_source.rb', line 17

def execute name
  object.const_source_location name
rescue NameError
  "ERROR: Invalid constant (#{name.inspect})."
end