Class: CrashLog::Backtrace::LineCache

Inherits:
Object
  • Object
show all
Defined in:
lib/crash_log/backtrace/line_cache.rb

Constant Summary collapse

CACHE =
{}

Class Method Summary collapse

Class Method Details

.getline(path, n) ⇒ Object



15
16
17
18
# File 'lib/crash_log/backtrace/line_cache.rb', line 15

def getline(path, n)
  return nil if n < 1
  getlines(path)[n-1]
end

.getlines(path) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/crash_log/backtrace/line_cache.rb', line 7

def getlines(path)
  CACHE[path] ||= begin
    IO.readlines(path).map { |line| line.chomp.gsub(/[']/, '\\\\\'') }
  rescue
    []
  end
end