Module: TraceLineNumbers
- Defined in:
- lib/linecache/trace_nums.rb,
lib/linecache/tracelines.rb,
ext/linecache/trace_nums.c
Overview
require ‘ruby-debug’ ; Debugger.start(:post-mortem => true)
Class Method Summary collapse
-
.lnums_for_file(file) ⇒ Object
Return an array of lines numbers that could be stopped at given a file name of a Ruby program.
-
.lnums_for_str(src) ⇒ Object
Return a list of trace hook line numbers for the string in Ruby source src.
-
.lnums_for_str_array(string_array, newline = '') ⇒ Object
Return an array of lines numbers that could be stopped at given a file name of a Ruby program.
Class Method Details
.lnums_for_file(file) ⇒ Object
Return an array of lines numbers that could be stopped at given a file name of a Ruby program.
16 17 18 |
# File 'lib/linecache/tracelines.rb', line 16 def lnums_for_file(file) lnums_for_str(File.read(file)) end |
.lnums_for_str(src) ⇒ Object
Return a list of trace hook line numbers for the string in Ruby source src
6 7 8 |
# File 'lib/linecache/trace_nums.rb', line 6 def lnums_for_str(code) (1..code.lines.count).to_a end |
.lnums_for_str_array(string_array, newline = '') ⇒ Object
Return an array of lines numbers that could be stopped at given a file name of a Ruby program. We assume the each line has n at the end. If not set the newline parameters to n.
25 26 27 |
# File 'lib/linecache/tracelines.rb', line 25 def lnums_for_str_array(string_array, newline='') lnums_for_str(string_array.join(newline)) end |