Sha256: 386cf5340d8b535e94ad231a35aad24f87cb7ca0b924d0f9b4341ef9f0210c95
Contents?: true
Size: 735 Bytes
Versions: 1
Compression:
Stored size: 735 Bytes
Contents
require 'file' require 'pathname' module Zikrash class CodeExtractor attr_accessor :file_location attr_accessor :line_number def initialize(backtrace_line) self.file_location = backtrace_line.split(':')[0].to_s self.line_number = backtrace_line.split(':')[1].to_i self end def result retrieve_code_lines end private def retrieve_code_lines code_lines = {} File.open(Pathname.new(file_location).realpath.to_s) do |file| file.each_line.with_index(1) do |line, index| code_lines[index] = line if index.between?(line_number - 5, line_number + 5) break if index > line_number + 5 end end code_lines end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zikrash-0.1.1 | lib/zikrash/code_extractor.rb |