Class: Byebug::MethodCommand
- Inherits:
-
Command
- Object
- Command
- Byebug::MethodCommand
show all
- Includes:
- Columnize
- Defined in:
- lib/byebug/commands/method.rb
Overview
Implements byebug’s ‘method’ command.
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
30
31
32
33
34
|
# File 'lib/byebug/commands/method.rb', line 30
def description
%{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
|
.names ⇒ Object
26
27
28
|
# File 'lib/byebug/commands/method.rb', line 26
def names
%w(method)
end
|
Instance Method Details
#execute ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/byebug/commands/method.rb', line 10
def execute
obj = bb_eval(@match.post_match)
if @match[1] == 'iv'
obj.instance_variables.sort.each do |v|
print "#{v} = #{obj.instance_variable_get(v).inspect}\n"
end
elsif @match[1]
print "#{columnize(obj.methods.sort(), Setting[:width])}\n"
elsif !obj.kind_of?(Module)
print "Should be Class/Module: #{@match.post_match}\n"
else
print "#{columnize(obj.instance_methods(false).sort(), Setting[:width])}\n"
end
end
|
#regexp ⇒ Object
6
7
8
|
# File 'lib/byebug/commands/method.rb', line 6
def regexp
/^\s* m(?:ethod)? \s+ ((iv)|(i(:?nstance)?)\s+)?/x
end
|