class Debugger::MethodCommand

Implements the debugger 'method' command.

Public Class Methods

help(cmd) click to toggle source
# File cli/ruby-debug/commands/method.rb, line 74
def help(cmd)
  %Q{
    m[ethod] i[nstance] <obj>\tshow methods of object
    m[ethod] iv <obj>\t\tshow instance variables of object
    m[ethod] <class|module>\t\tshow instance methods of class or module
  }
end
help_command() click to toggle source
# File cli/ruby-debug/commands/method.rb, line 70
def help_command
  'method'
end

Public Instance Methods

execute() click to toggle source
# File cli/ruby-debug/commands/method.rb, line 48
def execute
  if @match[1] == "iv"
    obj = debug_eval(@match.post_match)
    obj.instance_variables.sort.each do |v|
      print "%s = %s\n", v, obj.instance_variable_get(v).inspect
    end
  elsif @match[1]
    obj = debug_eval(@match.post_match)
    print "%s\n", columnize(obj.methods.sort(), 
                            self.class.settings[:width])
  else
    obj = debug_eval(@match.post_match)
    unless obj.kind_of? Module
      print "Should be Class/Module: %s\n", @match.post_match
    else
      print "%s\n", columnize(obj.instance_methods(false).sort(), 
                              self.class.settings[:width])
    end
  end
end
regexp() click to toggle source
# File cli/ruby-debug/commands/method.rb, line 44
def regexp
  /^\s*m(?:ethod)?\s+((iv)|(i(:?nstance\s+)?)\s+)?/
end