Class: Byebug::MethodCommand
- Inherits:
-
Command
- Object
- Command
- Byebug::MethodCommand
show all
- Includes:
- Columnize
- Defined in:
- lib/byebug/commands/method.rb
Overview
Show methods of specific classes/modules/objects.
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match
Class Method Details
.description ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/byebug/commands/method.rb', line 28
def description
%{m[ethod] (i[nstance][ <obj>]|<class|module>)
When invoked with "instance", shows instance methods of the object
specified as argument or of self no object was specified.
When invoked only with a class or module, shows class methods of the
class or module specified as argument.}
end
|
.names ⇒ Object
24
25
26
|
# File 'lib/byebug/commands/method.rb', line 24
def names
%w(method)
end
|
Instance Method Details
#execute ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/byebug/commands/method.rb', line 12
def execute
obj = bb_eval(@match.post_match)
if @match[1]
puts "#{columnize(obj.methods.sort, Setting[:width])}"
elsif !obj.is_a?(Module)
puts "Should be Class/Module: #{@match.post_match}"
else
puts "#{columnize(obj.instance_methods(false).sort, Setting[:width])}"
end
end
|
#regexp ⇒ Object
8
9
10
|
# File 'lib/byebug/commands/method.rb', line 8
def regexp
/^\s* m(?:ethod)? \s+ (i(:?nstance)?\s+)?/x
end
|