Class: Debugger::MethodCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/ruby-debug/commands/method.rb

Overview

:nodoc:

Constant Summary

Constants inherited from Command

Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, inherited, #initialize, load_commands, #match, method_missing, options

Constructor Details

This class inherits a constructor from Debugger::Command

Class Method Details

.help(cmd) ⇒ Object



45
46
47
48
49
50
# File 'lib/ruby-debug/commands/method.rb', line 45

def help(cmd)
  %{
    m[ethod] i[nstance] <obj>\tshow methods of object
    m[ethod] <class|module>\t\tshow instance methods of class or module
  }
end

.help_commandObject



41
42
43
# File 'lib/ruby-debug/commands/method.rb', line 41

def help_command
  'method'
end

Instance Method Details

#executeObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ruby-debug/commands/method.rb', line 7

def execute
  if @match[1]
    obj = debug_eval(@match.post_match)

    len = 0
    for v in obj.methods.sort
      len += v.size + 1
      if len > 70
        len = v.size + 1
        print "\n"
      end
      print "%s ", v
    end
    print "\n"
  else
    obj = debug_eval(@match.post_match)
    unless obj.kind_of? Module
      print "Should be Class/Module: %s\n", @match.post_match
    else
      len = 0
      for v in obj.instance_methods(false).sort
        len += v.size + 1
        if len > 70
          len = v.size + 1
          print "\n"
        end
        print "%s ", v
      end
      print "\n"
    end
  end
end

#regexpObject



3
4
5
# File 'lib/ruby-debug/commands/method.rb', line 3

def regexp
  /^\s*m(?:ethod)?\s+(?:(i(:?nstance)?)\s)?/
end