method
find_symbol
v1_8_7_330 -
Show latest stable
- Class:
RDoc::Context
find_symbol(symbol, method=nil)public
Look up the given symbol. If method is non-nil, then we assume the symbol references a module that contains that method
# File lib/rdoc/code_objects.rb, line 377
def find_symbol(symbol, method=nil)
result = nil
case symbol
when /^::(.*)/
result = toplevel.find_symbol($1)
when /::/
modules = symbol.split(/::/)
unless modules.empty?
module_name = modules.shift
result = find_module_named(module_name)
if result
modules.each do |module_name|
result = result.find_module_named(module_name)
break unless result
end
end
end
else
# if a method is specified, then we're definitely looking for
# a module, otherwise it could be any symbol
if method
result = find_module_named(symbol)
else
result = find_local_symbol(symbol)
if result.nil?
if symbol =~ /^[A-Z]/
result = parent
while result && result.name != symbol
result = result.parent
end
end
end
end
end
if result && method
if !result.respond_to?(:find_local_symbol)
p result.name
p method
fail
end
result = result.find_local_symbol(method)
end
result
end Related methods
- Instance methods
- <=>
- add_alias
- add_attribute
- add_class
- add_class_or_module
- add_constant
- add_include
- add_method
- add_module
- add_require
- add_to
- classes
- defined_in?
- each_attribute
- each_classmodule
- each_constant
- each_method
- find_enclosing_module_named
- find_local_symbol
- find_module_named
- find_symbol
- initialize_classes_and_modules
- initialize_methods_etc
- modules
- ongoing_visibility=
- record_location
- remove_classes_and_modules
- remove_methods_etc
- set_current_section
- set_visibility_for
- toplevel
- Class methods
- new
- Private methods
-
find_attribute_named -
find_constant_named -
find_instance_method_named -
find_method_named