module Kernel

ml_gems/util.rb

Public Instance Methods

fm(c, m = nil, output = false) click to toggle source
# File lib/mlhch/util.rb, line 6
def fm c, m = nil, output = false
  if c.is_a? Class
  current_klass = c
  else
    if c.is_a? Symbol
      current_klass = self.class === Class ? self : self.class
    m = c
    end
  end

  s = ["Searching class method '#{m}' of #{current_klass}..."]
  current_klass.ancestors.each do |klass|
    begin
      s << sprintf("%-40s - %-40s", klass, klass.method(m).source_location.join(':').gsub(/.*(app|gems)\//, ''))
    rescue
      nil
    end
  end
  s << "Searching instance method '#{m}' of #{current_klass}..."
  current_klass.ancestors.each do |klass|
    begin
      s << sprintf("%-40s - %-40s", klass, klass.instance_method(m).source_location.join(':').gsub(/.*(app|gems)\//, ''))
    rescue
      nil
    end
  end
  if output
    return '<pre>' + (s.map { |a| a = ERB::Util.html_escape(a) }.join("\n")) + '</pre>'
  else
    puts s.join("\n")
  end
end
pcall() click to toggle source
# File lib/mlhch/util.rb, line 39
def pcall
  caller.reverse.each_with_index do |a, i|
    printf "%3s : %s\n", i, a.gsub(/.*(lib|ruby)\//, '')
  end
end