Class: Byebug::FinishCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/byebug/commands/finish.rb

Overview

Implements the finish functionality.

Allows the user to continue execution until certain frames are finished.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, #match

Methods included from StringFunctions

#camelize, #prettify

Methods included from FileFunctions

#get_line, #get_lines, #n_lines, #normalize

Methods included from ParseFunctions

#get_int, #parse_steps, #syntax_valid?

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



36
37
38
39
40
41
42
43
44
# File 'lib/byebug/commands/finish.rb', line 36

def description
  prettify <<-EOD
    fin[ish][ n_frames]  Execute until frame returns.

    If no number is given, we run until the current frame returns. If a
    number of frames `n_frames` is given, then we run until `n_frames`
    return from the current position.
  EOD
end

.namesObject



32
33
34
# File 'lib/byebug/commands/finish.rb', line 32

def names
  %w(finish)
end

Instance Method Details

#executeObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/byebug/commands/finish.rb', line 16

def execute
  max_frames = @state.context.stack_size - @state.frame
  if @match[1]
    n_frames, err = get_int(@match[1], 'finish', 0, max_frames - 1)
    return errmsg(err) unless n_frames
  else
    n_frames = 1
  end

  force = n_frames == 0 ? true : false
  @state.context.step_out(@state.frame + n_frames, force)
  @state.frame = 0
  @state.proceed
end

#regexpObject



12
13
14
# File 'lib/byebug/commands/finish.rb', line 12

def regexp
  /^\s* fin(?:ish)? (?:\s+(\S+))? \s*$/x
end