Class: Packwerk::Offense
- Inherits:
-
Object
show all
- Defined in:
- lib/packwerk/offense.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(file:, message:, location: nil) ⇒ Offense
Returns a new instance of Offense.
18
19
20
21
22
|
# File 'lib/packwerk/offense.rb', line 18
def initialize(file:, message:, location: nil)
@location = location
@file = file
@message = message
end
|
Instance Attribute Details
#file ⇒ Object
12
13
14
|
# File 'lib/packwerk/offense.rb', line 12
def file
@file
end
|
#location ⇒ Object
9
10
11
|
# File 'lib/packwerk/offense.rb', line 9
def location
@location
end
|
#message ⇒ Object
15
16
17
|
# File 'lib/packwerk/offense.rb', line 15
def message
@message
end
|
Instance Method Details
#to_s(style = OutputStyles::Plain.new) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/packwerk/offense.rb', line 25
def to_s(style = OutputStyles::Plain.new)
location = self.location
if location
<<~EOS
#{style.filename}#{file}#{style.reset}:#{location.line}:#{location.column}
#{@message}
EOS
else
<<~EOS
#{style.filename}#{file}#{style.reset}
#{@message}
EOS
end
end
|