Class: Packwerk::Offense
- Inherits:
-
Object
- Object
- Packwerk::Offense
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/packwerk/offense.rb
Direct Known Subclasses
FileProcessor::UnknownFileTypeResult, Parsers::ParseResult, ReferenceOffense
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(file:, message:, location: nil) ⇒ Offense
constructor
A new instance of Offense.
- #to_s(style = OutputStyles::Plain.new) ⇒ Object
Constructor Details
#initialize(file:, message:, location: nil) ⇒ Offense
Returns a new instance of Offense.
24 25 26 27 28 |
# File 'lib/packwerk/offense.rb', line 24 def initialize(file:, message:, location: nil) @location = location @file = file @message = end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
15 16 17 |
# File 'lib/packwerk/offense.rb', line 15 def file @file end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
12 13 14 |
# File 'lib/packwerk/offense.rb', line 12 def location @location end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
18 19 20 |
# File 'lib/packwerk/offense.rb', line 18 def @message end |
Instance Method Details
#to_s(style = OutputStyles::Plain.new) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/packwerk/offense.rb', line 31 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 |