Class: Byebug::ListCommand
- Includes:
- Helpers::FileHelper, Helpers::ParseHelper
- Defined in:
- lib/byebug/commands/list.rb
Overview
List parts of the source code.
Instance Attribute Summary
Attributes inherited from Command
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Helpers::ParseHelper
#get_int, #parse_steps, #syntax_valid?
Methods included from Helpers::FileHelper
#get_line, #get_lines, #n_lines, #normalize, #shortpath, #virtual_file?
Methods inherited from Command
#arguments, columnize, #context, #frame, help, #initialize, match, to_s
Methods included from Helpers::StringHelper
Constructor Details
This class inherits a constructor from Byebug::Command
Class Method Details
.description ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/byebug/commands/list.rb', line 19 def self.description <<-EOD l[ist][[-=]][ nn-mm] #{short_description} Lists lines 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 |
.regexp ⇒ Object
15 16 17 |
# File 'lib/byebug/commands/list.rb', line 15 def self.regexp /^\s* l(?:ist)? (?:\s*([-=])|\s+(\S+))? \s*$/x end |
.short_description ⇒ Object
33 34 35 |
# File 'lib/byebug/commands/list.rb', line 33 def self.short_description 'Lists lines of source code' end |
Instance Method Details
#execute ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/byebug/commands/list.rb', line 37 def execute msg = "No sourcefile available for #{frame.file}" fail(msg) unless File.exist?(frame.file) max_lines = n_lines(frame.file) b, e = range(@match[2], max_lines) fail('Invalid line range') unless valid_range?(b, e, max_lines) display_lines(b, e) processor.prev_line = b end |