Class: EagerEye::Issue
- Inherits:
-
Object
- Object
- EagerEye::Issue
- Defined in:
- lib/eager_eye/issue.rb
Constant Summary collapse
- VALID_SEVERITIES =
%i[warning error].freeze
Instance Attribute Summary collapse
-
#detector ⇒ Object
readonly
Returns the value of attribute detector.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
-
#suggestion ⇒ Object
readonly
Returns the value of attribute suggestion.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(detector:, file_path:, line_number:, message:, severity: :warning, suggestion: nil) ⇒ Issue
constructor
A new instance of Issue.
- #to_h ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(detector:, file_path:, line_number:, message:, severity: :warning, suggestion: nil) ⇒ Issue
Returns a new instance of Issue.
9 10 11 12 13 14 15 16 |
# File 'lib/eager_eye/issue.rb', line 9 def initialize(detector:, file_path:, line_number:, message:, severity: :warning, suggestion: nil) @detector = detector @file_path = file_path @line_number = line_number @message = @severity = validate_severity(severity) @suggestion = suggestion end |
Instance Attribute Details
#detector ⇒ Object (readonly)
Returns the value of attribute detector.
5 6 7 |
# File 'lib/eager_eye/issue.rb', line 5 def detector @detector end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
5 6 7 |
# File 'lib/eager_eye/issue.rb', line 5 def file_path @file_path end |
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
5 6 7 |
# File 'lib/eager_eye/issue.rb', line 5 def line_number @line_number end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/eager_eye/issue.rb', line 5 def @message end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
5 6 7 |
# File 'lib/eager_eye/issue.rb', line 5 def severity @severity end |
#suggestion ⇒ Object (readonly)
Returns the value of attribute suggestion.
5 6 7 |
# File 'lib/eager_eye/issue.rb', line 5 def suggestion @suggestion end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/eager_eye/issue.rb', line 33 def ==(other) return false unless other.is_a?(Issue) detector == other.detector && file_path == other.file_path && line_number == other.line_number && == other. && severity == other.severity && suggestion == other.suggestion end |
#hash ⇒ Object
46 47 48 |
# File 'lib/eager_eye/issue.rb', line 46 def hash [detector, file_path, line_number, , severity, suggestion].hash end |
#to_h ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/eager_eye/issue.rb', line 18 def to_h { detector: detector, file_path: file_path, line_number: line_number, message: , severity: severity, suggestion: suggestion } end |
#to_json(*args) ⇒ Object
29 30 31 |
# File 'lib/eager_eye/issue.rb', line 29 def to_json(*args) to_h.to_json(*args) end |