Class: Byebug::FinishCommand

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

Overview

Implements the finish functionality.

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

Instance Attribute Summary

Attributes inherited from Command

#processor

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::ParseHelper

#get_int, #parse_steps, #syntax_valid?

Methods inherited from Command

#arguments, columnize, #context, #frame, help, #initialize, match, to_s

Methods included from Helpers::StringHelper

#camelize, #prettify

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



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

def self.description
  <<-EOD
    fin[ish][ n_frames]

    #{short_description}

    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

.regexpObject



15
16
17
# File 'lib/byebug/commands/finish.rb', line 15

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

.short_descriptionObject



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

def self.short_description
  'Runs the program until frame returns'
end

Instance Method Details

#executeObject



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

def execute
  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
  context.step_out(context.frame.pos + n_frames, force)
  context.frame = 0
  processor.proceed!
end