public Method

TemplateError.source_extract(indentation = 0)

There's no documentation for this item.

Source Code

# File action_view/template_error.rb, line 33
def source_extract(indentation = 0)
  return unless num = line_number
  num = num.to_i

  source_code = IO.readlines(@file_path)

  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

  source_code[start_on_line..end_on_line].sum do |line|
    line_counter += 1
    "#{indent}#{line_counter}: #{line}"
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.