Class: Policial::Violation

Inherits:
Object
  • Object
show all
Defined in:
lib/policial/violation.rb

Overview

Public: Hold file, line, and message. Built by style guides.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, line_number, message, linter) ⇒ Violation

Returns a new instance of Violation.



8
9
10
11
12
13
# File 'lib/policial/violation.rb', line 8

def initialize(file, line_number, message, linter)
  @file        = file
  @line_number = line_number
  @message     = message
  @linter      = linter
end

Instance Attribute Details

#line_numberObject (readonly)

Returns the value of attribute line_number.



6
7
8
# File 'lib/policial/violation.rb', line 6

def line_number
  @line_number
end

#linterObject (readonly)

Returns the value of attribute linter.



6
7
8
# File 'lib/policial/violation.rb', line 6

def linter
  @linter
end

#messageObject (readonly)

Returns the value of attribute message.



6
7
8
# File 'lib/policial/violation.rb', line 6

def message
  @message
end

Instance Method Details

#filenameObject



15
16
17
# File 'lib/policial/violation.rb', line 15

def filename
  @file.filename
end

#lineObject



19
20
21
# File 'lib/policial/violation.rb', line 19

def line
  @line ||= @file.line_at(line_number)
end

#on_changed_line?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/policial/violation.rb', line 27

def on_changed_line?
  line.changed?
end

#patch_positionObject



23
24
25
# File 'lib/policial/violation.rb', line 23

def patch_position
  line.patch_position
end