Class: Byebug::JumpCommand
Overview
Implements byebug “jump” command
Constant Summary
Constants inherited
from Command
Command::DEF_OPTIONS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, find, format_subcmd, format_subcmds, 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
50
51
52
53
54
55
56
|
# File 'lib/byebug/commands/jump.rb', line 50
def description
%{j[ump] line\tjump to line number (absolute)
j[ump] -line\tjump back to line (relative)
j[ump] +line\tjump ahead to line (relative)
Change the next line of code to be executed.}
end
|
.names ⇒ Object
46
47
48
|
# File 'lib/byebug/commands/jump.rb', line 46
def names
%w(jump)
end
|
Instance Method Details
#execute ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/byebug/commands/jump.rb', line 20
def execute
return errmsg "\"jump\" must be followed by a line number\n" unless @match[1]
return errmsg "Bad line number: " + @match[1] unless numeric?(@match[1])
line = @match[1].to_i
line = @state.context.frame_line(0) + line if @match[1][0] == '+' or @match[1][0] == '-'
if line == @state.context.frame_line(0)
CommandProcessor.print_location_and_text(@state.context.frame_file(0), line)
return
end
file = @match[2]
file = @state.context.frame_file(file.to_i) if numeric?(file)
file = @state.context.frame_file(0) if !file
case Byebug.context.jump(line, file)
when 0
@state.proceed
when 1
errmsg "Not possible to jump from here\n"
when 2
errmsg "Couldn't find debugged frame\n"
when 3
errmsg "Couldn't find active code at " + file + ":" + line.to_s + "\n"
end
end
|
#numeric?(object) ⇒ Boolean
7
8
9
|
# File 'lib/byebug/commands/jump.rb', line 7
def numeric?(object)
true if Float(object) rescue false
end
|
#regexp ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/byebug/commands/jump.rb', line 11
def regexp
/ ^\s*
j(?:ump)? \s*
(?:\s+(\S+))?\s*
(?:\s+(\S+))?\s*
$
/ix
end
|