class Hoss::Stacktrace::Frame
@api private
Attributes
abs_path[RW]
colno[RW]
context_line[RW]
filename[RW]
function[RW]
library_frame[RW]
lineno[RW]
module[RW]
post_context[RW]
pre_context[RW]
vars[RW]
Public Instance Methods
build_context(context_line_count)
click to toggle source
# File lib/hoss/stacktrace/frame.rb, line 41 def build_context(context_line_count) return unless abs_path && context_line_count > 0 padding = (context_line_count - 1) / 2 from = lineno - padding - 1 from = 0 if from < 0 to = lineno + padding - 1 file_lines = read_lines(abs_path, from..to) return unless file_lines self.context_line = file_lines[padding] self.pre_context = file_lines.first(padding) self.post_context = file_lines.last(padding) end
Private Instance Methods
read_lines(path, range)
click to toggle source
# File lib/hoss/stacktrace/frame.rb, line 59 def read_lines(path, range) File.readlines(path)[range] rescue Errno::ENOENT nil end