Module: Pry::MethodInfo
- Defined in:
- lib/pry-doc/pry_ext/method_info.rb
Constant Summary collapse
- METHOD_INSPECT_PATTERN =
Returns a pattern that matches
method_instance.inspect
. if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0") %r{\A \#< (?:Unbound)?Method:\s (.+) # Method owner such as "BigDecimal" ([\#\.].+?) # Method signature such as ".finite?" or "#finite?" \(.*\) # Param list (?: \s/.+\.rb:\d+ # Source location )? .* # Sometimes there's gibberish like "<main>:0", we ignore that > \z}x else %r{\A \#< (?:Unbound)?Method:\s (.+) # Method owner such as "BigDecimal" ([\#\.].+?) # Method signature such as ".finite?" or "#finite?" (?: \(.*\) # Param list )? > \z}x end
Class Method Summary collapse
-
.aliases(meth) ⇒ Array<UnboundMethod>
Retrieves aliases of the given method.
-
.gem_root(dir) ⇒ String
FIXME: this is unnecessarily limited to ext/ and lib/ directories.
-
.info_for(meth) ⇒ YARD::CodeObjects::MethodObject
Retrieve the YARD object that contains the method data.
Class Method Details
.aliases(meth) ⇒ Array<UnboundMethod>
Retrieves aliases of the given method.
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/pry-doc/pry_ext/method_info.rb', line 56 def aliases(meth) owner = meth.owner name = meth.name (owner.instance_methods + owner.private_instance_methods).uniq.map do |m| aliased_method = owner.__send__(:instance_method, m) next unless aliased_method == owner.__send__(:instance_method, name) next if m == name aliased_method end.compact! end |
.gem_root(dir) ⇒ String
FIXME: this is unnecessarily limited to ext/ and lib/ directories.
73 74 75 76 |
# File 'lib/pry-doc/pry_ext/method_info.rb', line 73 def gem_root(dir) return unless (index = dir.rindex(%r(/(?:lib|ext)(?:/|$)))) dir[0..index-1] end |
.info_for(meth) ⇒ YARD::CodeObjects::MethodObject
Retrieve the YARD object that contains the method data.
45 46 47 48 |
# File 'lib/pry-doc/pry_ext/method_info.rb', line 45 def info_for(meth) cache(meth) registry_lookup(meth) end |