Class: Byebug::UndisplayCommand

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

Overview

Remove expressions from display list.

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



34
35
36
37
38
39
40
41
42
# File 'lib/byebug/commands/undisplay.rb', line 34

def description
  %(undisp[lay][ nnn]

    Cancel some expressions to be displayed when program stops. Arguments
    are the code numbers of the expressions to stop displaying. No
    argument means cancel all automatic-display expressions. "delete
    display" has the same effect as this command. Do "info display" to see
    the current list of code numbers.)
end

.namesObject



30
31
32
# File 'lib/byebug/commands/undisplay.rb', line 30

def names
  %w(undisplay)
end

Instance Method Details

#executeObject



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

def execute
  if @match[1]
    pos, err = get_int(@match[1], 'Undisplay')
    return errmsg(err) unless pos

    unless @state.display[pos - 1]
      return errmsg("Display expression #{pos} is not defined.")
    end

    @state.display[pos - 1][0] = nil
  else
    return unless confirm('Clear all expressions? (y/n) ')

    @state.display.each { |d| d[0] = false }
  end
end

#regexpObject



8
9
10
# File 'lib/byebug/commands/undisplay.rb', line 8

def regexp
  /^\s* undisp(?:lay)? (?:\s+(\S+))? \s*$/x
end