Class: Byebug::DisplayCommand

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

Overview

Custom expressions to be displayed every time the debugger stops.

Instance Attribute Summary

Attributes inherited from Command

#processor

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::EvalHelper

#error_eval, #multiple_thread_eval, #separate_thread_eval, #silent_eval, #warning_eval

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/display.rb', line 20

def self.description
  <<-DESCRIPTION
    disp[lay][ <expression>]

    #{short_description}

    If <expression> specified, adds <expression> into display expression
    list. Otherwise, it lists all expressions.
  DESCRIPTION
end

.regexpObject



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

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

.short_descriptionObject



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

def self.short_description
  "Evaluates expressions every time the debugger stops"
end

Instance Method Details

#executeObject



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

def execute
  return print_display_expressions unless @match && @match[1]

  Byebug.displays.push [true, @match[1]]
  display_expression(@match[1])
end