Skip to content

Instantly share code, notes, and snippets.

@wanabe
Created June 3, 2012 17:09
Show Gist options
  • Save wanabe/2864174 to your computer and use it in GitHub Desktop.
Save wanabe/2864174 to your computer and use it in GitHub Desktop.
Index: tools/bc-methods.rb
===================================================================
--- tools/bc-methods.rb (revision 5176)
+++ tools/bc-methods.rb (working copy)
@@ -158,10 +158,11 @@ def defined_methods(ruby, classname)
c.singleton_methods(false).each do |m|
puts "#{classname}.\#{m}"
end
+ opt = Kernel.method(:const_defined?).arity == 1 ? [] : [false]
c.instance_methods(false).each do |m|
puts "#{classname}\\#\#{m}"
end
- c.ancestors.map {|mod| mod.constants }.inject {|r,n| r-n }.each do |m|
+ c.constants.select{|const| c.const_defined?(const, *opt)}.each do |m|
puts "#{classname}::\#{m}"
end
'`.split
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment