Class: Byebug::ConditionCommand
- Inherits:
-
Command
- Object
- Command
- Byebug::ConditionCommand
show all
- Defined in:
- lib/byebug/commands/condition.rb
Constant Summary
Constants inherited
from Command
Byebug::Command::DEF_OPTIONS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match, method_missing, options, register_setting_get, register_setting_set, register_setting_var, settings, settings_map
Class Method Details
.description ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/byebug/commands/condition.rb', line 33
def description
%{cond[ition] nnn[ expr]
Specify breakpoint number nnn to break only if expr is true. nnn is an
integer and expr is an expression to be evaluated whenever breakpoint
nnn is reached. If no expression is specified, the condition is
removed.}
end
|
.names ⇒ Object
29
30
31
|
# File 'lib/byebug/commands/condition.rb', line 29
def names
%w(condition)
end
|
Instance Method Details
#execute ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/byebug/commands/condition.rb', line 9
def execute
return errmsg "\"condition\" must be followed by " \
"breakpoint number and expression\n" unless @match[1]
breakpoints = Byebug.breakpoints.sort_by{|b| b.id }
largest = breakpoints.inject(0) do |tally, b|
tally = b.id if b.id > tally
end
return print "No breakpoints have been set.\n" if 0 == largest
return unless pos = get_int(@match[1], "Condition", 1, largest)
breakpoints.each do |b|
if b.id == pos
b.expr = @match[2].empty? ? nil : @match[2]
break
end
end
end
|
#regexp ⇒ Object
5
6
7
|
# File 'lib/byebug/commands/condition.rb', line 5
def regexp
/^\s* cond(?:ition)? (?:\s+(\d+)\s*(.*))?$/ix
end
|