Class: RailsBestPractices::Core::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_best_practices/core/error.rb

Overview

Error is the violation to rails best practice.

it indicates the filenname, line number and error message for the violation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, line_number, message, url = nil) ⇒ Error

Returns a new instance of Error.



10
11
12
13
14
15
# File 'lib/rails_best_practices/core/error.rb', line 10

def initialize(filename, line_number, message, url = nil)
  @filename = filename
  @line_number = line_number
  @message = message
  @url = url
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



8
9
10
# File 'lib/rails_best_practices/core/error.rb', line 8

def filename
  @filename
end

#line_numberObject (readonly)

Returns the value of attribute line_number.



8
9
10
# File 'lib/rails_best_practices/core/error.rb', line 8

def line_number
  @line_number
end

#messageObject (readonly)

Returns the value of attribute message.



8
9
10
# File 'lib/rails_best_practices/core/error.rb', line 8

def message
  @message
end

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'lib/rails_best_practices/core/error.rb', line 8

def url
  @url
end

Instance Method Details

#to_sObject



17
18
19
# File 'lib/rails_best_practices/core/error.rb', line 17

def to_s
  "#{@filename}:#{@line_number} - #{@message}"
end