Module: Byebug::Helpers::ToggleHelper

Overview

Utilities to assist breakpoint/display enabling/disabling.

Instance Method Summary collapse

Methods included from ParseHelper

#get_int, #parse_steps, #syntax_valid?

Instance Method Details

#enable_disable_breakpoints(is_enable, args) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/byebug/helpers/toggle.rb', line 13

def enable_disable_breakpoints(is_enable, args)
  raise pr("toggle.errors.no_breakpoints") if Breakpoint.none?

  select_breakpoints(is_enable, args).each do |b|
    enabled = (is_enable == "enable")
    raise pr("toggle.errors.expression", expr: b.expr) if enabled && !syntax_valid?(b.expr)

    puts pr("toggle.messages.toggled", bpnum: b.id,
                                       endis: enabled ? "en" : "dis")
    b.enabled = enabled
  end
end

#enable_disable_display(is_enable, args) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/byebug/helpers/toggle.rb', line 26

def enable_disable_display(is_enable, args)
  raise pr("toggle.errors.no_display") if n_displays.zero?

  selected_displays = args ? args.split(/ +/) : [1..n_displays + 1]

  selected_displays.each do |pos|
    pos, err = get_int(pos, "#{is_enable} display", 1, n_displays)
    raise err unless err.nil?

    Byebug.displays[pos - 1][0] = (is_enable == "enable")
  end
end