Class: Byebug::SkipCommand

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

Overview

Allows the user to continue execution until the next breakpoint, as long as it is different from the current one

Class Attribute Summary collapse

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, #deindent, #prettify

Constructor Details

This class inherits a constructor from Byebug::Command

Class Attribute Details

.file_lineObject



17
18
19
# File 'lib/byebug/commands/skip.rb', line 17

def file_line
  @file_line ||= 0
end

.file_pathObject



21
22
23
# File 'lib/byebug/commands/skip.rb', line 21

def file_path
  @file_path ||= ""
end

Class Method Details

.descriptionObject



30
31
32
33
34
35
36
# File 'lib/byebug/commands/skip.rb', line 30

def self.description
  <<-DESCRIPTION
    sk[ip]

    #{short_description}
  DESCRIPTION
end

.regexpObject



26
27
28
# File 'lib/byebug/commands/skip.rb', line 26

def self.regexp
  /^\s* sk(?:ip)? \s*$/x
end

.short_descriptionObject



38
39
40
# File 'lib/byebug/commands/skip.rb', line 38

def self.short_description
  "Runs until the next breakpoint as long as it is different from the current one"
end

Instance Method Details

#auto_runObject



56
57
58
59
60
61
# File 'lib/byebug/commands/skip.rb', line 56

def auto_run
  return false unless self.class.always_run == 2

  keep_execution ? processor.proceed! : reset_attributes
  true
end

#executeObject



63
64
65
66
67
68
69
# File 'lib/byebug/commands/skip.rb', line 63

def execute
  return if auto_run

  initialize_attributes
  processor.proceed!
  Byebug.stop if Byebug.stoppable?
end

#initialize_attributesObject



42
43
44
45
46
# File 'lib/byebug/commands/skip.rb', line 42

def initialize_attributes
  self.class.always_run = 2
  self.class.file_path = frame.file
  self.class.file_line = frame.line
end

#keep_executionObject



48
49
50
# File 'lib/byebug/commands/skip.rb', line 48

def keep_execution
  [self.class.file_path, self.class.file_line] == [frame.file, frame.line]
end

#reset_attributesObject



52
53
54
# File 'lib/byebug/commands/skip.rb', line 52

def reset_attributes
  self.class.always_run = 0
end