Class: Byebug::ThreadCommand

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

Overview

Manipulation of Ruby threads

Constant Summary collapse

Subcommands =
[
  ['current', 1, 'Shows current thread'],
  ['list', 1, 'Lists all threads'],
  ['resume', 1, 'Resumes execution of specified thread number'],
  ['stop', 2, 'Stops execution of specified thread number'],
  ['switch', 2, 'Switches execution to specified thread']
].map do |name, min, help|
  Subcmd.new(name, min, help)
end

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, #match

Methods included from StringFunctions

#camelize, #prettify

Methods included from FileFunctions

#get_line, #get_lines, #n_lines, #normalize

Methods included from ParseFunctions

#get_int, #parse_steps, #syntax_valid?, #without_stderr

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



37
38
39
40
41
# File 'lib/byebug/commands/thread.rb', line 37

def description
  prettify <<-EOD
    Commands to manipulate threads.
  EOD
end

.namesObject



33
34
35
# File 'lib/byebug/commands/thread.rb', line 33

def names
  %w(thread)
end

Instance Method Details

#executeObject



22
23
24
25
26
27
28
29
30
# File 'lib/byebug/commands/thread.rb', line 22

def execute
  return puts(self.class.help) unless @match[1]

  name, thnum = @match[1].split(/ +/)[0..1]
  subcmd = Command.find(Subcommands, name)
  return errmsg("Unknown thread command '#{name}'\n") unless subcmd

  send("thread_#{subcmd.name}", thnum)
end

#regexpObject



18
19
20
# File 'lib/byebug/commands/thread.rb', line 18

def regexp
  /^\s* th(?:read)? (?:\s+ (.+))? \s*$/x
end