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.
Constant Summary
Constants inherited
from Command
Command::DEF_OPTIONS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, help, inherited, #initialize, load_commands, #match, method_missing, options, register_setting_get, register_setting_set, register_setting_var, settings, settings_map
Class Method Details
.description ⇒ Object
75
76
77
78
79
80
81
|
# File 'lib/byebug/commands/method.rb', line 75
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
71
72
73
|
# File 'lib/byebug/commands/method.rb', line 71
def names
%w(method)
end
|
Instance Method Details
#execute ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/byebug/commands/method.rb', line 50
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(), Command.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(),
Command.settings[:width])
end
end
end
|
#regexp ⇒ Object
46
47
48
|
# File 'lib/byebug/commands/method.rb', line 46
def regexp
/^\s*m(?:ethod)?\s+((iv)|(i(:?nstance)?)\s+)?/
end
|