Class: Byebug::ListCommand

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

Overview

Implements byebug “list” command.

Constant Summary

Constants inherited from Command

Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, #find, inherited, #initialize, load_commands, #match, method_missing, options, #print_subcmds, register_setting_get, register_setting_set, register_setting_var, settings, settings_map

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.help(cmd) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/byebug/commands/list.rb', line 41

def help(cmd)
  %{
    l[ist]\t\tlist forward
    l[ist] -\tlist backward
    l[ist] =\tlist current line
    l[ist] nn-mm\tlist given lines
    * NOTE - to turn on autolist, use 'set autolist'
  }
end

.help_commandObject



37
38
39
# File 'lib/byebug/commands/list.rb', line 37

def help_command
  'list'
end

Instance Method Details

#executeObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/byebug/commands/list.rb', line 20

def execute
  Byebug.source_reload if Command.settings[:reload_source_on_change]
  lines = LineCache::getlines(@state.file,
                              Command.settings[:reload_source_on_change])
  if !lines
    errmsg "No sourcefile available for #{@state.file}\n"
    return @state.previous_line
  end

  b, e = set_line_range(Command.settings[:listsize], lines.size)
  return @state.previous_line if b < 0

  print "[#{b}, #{e}] in #{@state.file}\n"
  @state.previous_line = display_list(b, e, lines, @state.line)
end

#regexpObject



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

def regexp
  /^\s* l(?:ist)? (?:\s*([-=])|\s+(.+))? $/x
end