From: Tom Sawyer Date: 2003-01-06T19:50:55+09:00 Subject: Re: How many single Methods provides Ruby ? well here are two versions. using different methods, they both work. i don't know which is more accurate. but the second divides the job in two: Classes and Modules. anyone have a script that actually builds the hieararchy and thereby can get this exact? anyway, i think your looking at around 1000 methods. whew, thats a lot! VERSION 1: mt = 0; cm = 0; im = 0; Module.constants.each { |c| cnst = eval "#{c}" if cnst.respond_to?(:singleton_methods) cnst.singleton_methods.each { |m| puts m; cm +=1; mt +=1 } end if cnst.respond_to?(:public_instance_methods) cnst.public_instance_methods(false).each { |m| puts m; im +=1; mt +=1 } end } puts puts "Total Public Class Methods: #{cm}" puts "Total Public Instance Methods: #{im}" puts "Total Public Methods: #{mt}" VERSION 2: mt = 0; cm = 0; im = 0; ObjectSpace.each_object(Class) { |cnst| puts "\n\n#{cnst}\n===============================\n" cnst.singleton_methods.each { |m| print "#{m} "; cm +=1; mt +=1 } cnst.public_instance_methods(false).each { |m| print "#{m} "; im +=1; mt +=1 } } puts puts "Total Class Public Class Methods: #{cm}" puts "Total Class Public Instance Methods: #{im}" puts "Total Class Public Methods: #{mt}" mt2 = 0; cm2 = 0; im2 = 0; ObjectSpace.each_object(Module) { |cnst| puts "\n\n#{cnst}\n===============================\n" cnst.singleton_methods.each { |m| print "#{m} "; cm2 +=1; mt2 +=1 } cnst.public_instance_methods(false).each { |m| print "#{m} "; im2 +=1; mt2 +=1 } } puts puts "Total Module Public Class Methods: #{cm2}" puts "Total Module Public Instance Methods: #{im2}" puts "Total Module Public Methods: #{mt2}" tom sawyer, aka transami transami@transami.net .''. .''. . *''* :_\/_: . :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'. .''.: /\ : ./)\ ':'* /\ * : '..'. -=:o:=- :_\/_:'.:::. | ' *''* * '.\'/.' _\(/_'.':'.' : /\ : ::::: = *_\/_* -= o =- /)\ ' * '..' ':::' === * /\ * .'/.\'. '._____ * | *..* : |. |' .---"| * | _ .--'| || | _| | * | .-'| __ | | | || | .-----. | |' | || | | | | | || | ___' ' /"\ | '-."". '-' '-.' '` |_. ------------------------------------------------------------