Class: CodeAnalyzer::Warning

Inherits:
Object
  • Object
show all
Defined in:
lib/code_analyzer/warning.rb

Overview

Warning is the violation.

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Warning

Returns a new instance of Warning.



10
11
12
13
14
# File 'lib/code_analyzer/warning.rb', line 10

def initialize(options = {})
  @filename = options[:filename]
  @line_number = options[:line_number].to_s
  @message = options[:message]
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



8
9
10
# File 'lib/code_analyzer/warning.rb', line 8

def filename
  @filename
end

#line_numberObject (readonly)

Returns the value of attribute line_number.



8
9
10
# File 'lib/code_analyzer/warning.rb', line 8

def line_number
  @line_number
end

#messageObject (readonly)

Returns the value of attribute message.



8
9
10
# File 'lib/code_analyzer/warning.rb', line 8

def message
  @message
end

Instance Method Details

#to_sObject



16
17
18
# File 'lib/code_analyzer/warning.rb', line 16

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