# File lib/staticmatic/template_error.rb, line 26 def source_extract(indentation = 0) return "" unless num = line_number num = num.to_i source_code = @source.split("\n") start_on_line = [ num - SOURCE_CODE_RADIUS - 1, 0 ].max end_on_line = [ num + SOURCE_CODE_RADIUS - 1, source_code.length].min indent = ' ' * indentation line_counter = start_on_line return unless source_code = source_code[start_on_line..end_on_line] source_code.collect do |line| line_counter += 1 "#{indent}#{line_counter}: #{line}\n" end.to_s end