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



40
41
42
43
44
45
46
47
# File 'lib/byebug/commands/delete.rb', line 40

def description
  prettify <<-EOD
    del[ete][ nnn...]

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

.namesObject



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

def names
  %w(delete)
end

Instance Method Details

#executeObject



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

def execute
  unless @match[1]
    if confirm(pr('break.confirmations.delete_all'))
      Byebug.breakpoints.clear
    end

    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(pr('break.errors.no_breakpoint_delete', pos: pos))
    end
  end
end

#regexpObject



11
12
13
# File 'lib/byebug/commands/delete.rb', line 11

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