Class: Byebug::ListCommand
- Defined in:
- lib/byebug/commands/list.rb
Overview
List parts of the source code.
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
Methods included from FileFunctions
#get_line, #get_lines, #n_lines, #normalize
Methods included from ParseFunctions
#get_int, #parse_steps, #syntax_valid?
Constructor Details
This class inherits a constructor from Byebug::Command
Class Method Details
.description ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/byebug/commands/list.rb', line 31 def description prettify <<-EOD l[ist][[-=]][ nn-mm] Lists lines of code forward from current line or from the place where code was last listed. If "list-" is specified, lists backwards instead. If "list=" is specified, lists from current line regardless of where code was last listed. A line range can also be specified to list specific sections of code. EOD end |
.names ⇒ Object
27 28 29 |
# File 'lib/byebug/commands/list.rb', line 27 def names %w(list) end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/byebug/commands/list.rb', line 12 def execute exist = File.exist?(@state.file) return errmsg "No sourcefile available for #{@state.file}\n" unless exist @match ||= match('list') max_lines = n_lines(@state.file) b, e = range(@match[2], max_lines) return errmsg('Invalid line range') unless valid_range?(b, e, max_lines) display_lines(b, e) @state.prev_line = b end |
#regexp ⇒ Object
8 9 10 |
# File 'lib/byebug/commands/list.rb', line 8 def regexp /^\s* l(?:ist)? (?:\s*([-=])|\s+(\S+))? \s*$/x end |