Class: EagerEye::Issue
- Inherits:
-
Object
- Object
- EagerEye::Issue
- Defined in:
- lib/eager_eye/issue.rb
Constant Summary collapse
- VALID_SEVERITIES =
%i[info warning error].freeze
- SEVERITY_ORDER =
{ info: 0, warning: 1, error: 2 }.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.
- #meets_minimum_severity?(min_severity) ⇒ Boolean
- #severity_level ⇒ Object
- #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.
10 11 12 13 14 15 16 17 |
# File 'lib/eager_eye/issue.rb', line 10 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?
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/eager_eye/issue.rb', line 42 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
55 56 57 |
# File 'lib/eager_eye/issue.rb', line 55 def hash [detector, file_path, line_number, , severity, suggestion].hash end |
#meets_minimum_severity?(min_severity) ⇒ Boolean
23 24 25 |
# File 'lib/eager_eye/issue.rb', line 23 def meets_minimum_severity?(min_severity) severity_level >= SEVERITY_ORDER.fetch(min_severity, 0) end |
#severity_level ⇒ Object
19 20 21 |
# File 'lib/eager_eye/issue.rb', line 19 def severity_level SEVERITY_ORDER[severity] end |
#to_h ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/eager_eye/issue.rb', line 27 def to_h { detector: detector, file_path: file_path, line_number: line_number, message: , severity: severity, suggestion: suggestion } end |
#to_json(*args) ⇒ Object
38 39 40 |
# File 'lib/eager_eye/issue.rb', line 38 def to_json(*args) to_h.to_json(*args) end |