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
command_exists?, commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match, register_setting_get, register_setting_set, register_setting_var, settings, settings_map, terminal_width
Class Method Details
.description ⇒ Object
69
70
71
72
73
|
# File 'lib/byebug/commands/method.rb', line 69
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
65
66
67
|
# File 'lib/byebug/commands/method.rb', line 65
def names
%w(method)
end
|
Instance Method Details
#execute ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/byebug/commands/method.rb', line 48
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(), Command.settings[:width])}\n"
else
return print "Should be Class/Module: #{@match.post_match}\n" unless
obj.kind_of? Module
print "#{columnize(obj.instance_methods(false).sort(),
Command.settings[:width])}\n"
end
end
|
#regexp ⇒ Object
44
45
46
|
# File 'lib/byebug/commands/method.rb', line 44
def regexp
/^\s* m(?:ethod)? \s+ ((iv)|(i(:?nstance)?)\s+)?/x
end
|