Class: Byebug::DeleteCommand

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

Overview

Implements breakpoint deletion.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



36
37
38
39
40
41
# File 'lib/byebug/commands/delete.rb', line 36

def description
  %(del[ete][ nnn...]

    Without and argument, deletes all breakpoints. With integer
    arguments, it deletes specific breakpoints.)
end

.namesObject



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

def names
  %w(delete)
end

Instance Method Details

#executeObject



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

def execute
  unless @match[1]
    Byebug.breakpoints.clear if confirm('Delete all breakpoints? (y/n) ')

    return nil
  end

  @match[1].split(/[ \t]+/).each do |number|
    pos, err = get_int(number, 'Delete', 1)

    return errmsg(err) unless pos

    unless Breakpoint.remove(pos)
      return errmsg("No breakpoint number #{pos}")
    end
  end
end

#regexpObject



9
10
11
# File 'lib/byebug/commands/delete.rb', line 9

def regexp
  /^\s* del(?:ete)? (?:\s+(.*))?$/x
end