class ElasticAPM::Stacktrace::Frame

@api private

def build_context(context_line_count)

rubocop:disable Metrics/AbcSize
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)
  self.context_line = file_lines[padding]
  self.pre_context  = file_lines.first(padding)
  self.post_context = file_lines.last(padding)
end

def read_lines(path, range)

def read_lines(path, range)
  File.readlines(path)[range]
rescue Errno::ENOENT
  []
end