Class: Byebug::DeleteCommand

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

Overview

Implements breakpoint deletion.

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

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



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

def self.description
  <<-DESCRIPTION
    del[ete][ nnn...]

    #{short_description}

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

.regexpObject



16
17
18
# File 'lib/byebug/commands/delete.rb', line 16

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

.short_descriptionObject



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

def self.short_description
  "Deletes breakpoints"
end

Instance Method Details

#executeObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/byebug/commands/delete.rb', line 35

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

    return
  end

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

    return errmsg(err) unless pos

    if Breakpoint.remove(pos)
      puts(pr("break.messages.breakpoint_deleted", pos: pos))
    else
      errmsg(pr("break.errors.no_breakpoint_delete", pos: pos))
    end
  end
end