Class: RouteGuard::Models::Issue
- Inherits:
-
Object
- Object
- RouteGuard::Models::Issue
- Defined in:
- lib/route_guard/models/issue.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#related_routes ⇒ Object
readonly
Returns the value of attribute related_routes.
-
#route ⇒ Object
readonly
Returns the value of attribute route.
-
#rule_name ⇒ Object
readonly
Returns the value of attribute rule_name.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
Instance Method Summary collapse
-
#initialize(rule_name:, severity:, message:, route:, related_routes: [], file: nil, line: nil) ⇒ Issue
constructor
A new instance of Issue.
- #location ⇒ Object
Constructor Details
#initialize(rule_name:, severity:, message:, route:, related_routes: [], file: nil, line: nil) ⇒ Issue
Returns a new instance of Issue.
8 9 10 11 12 13 14 15 16 |
# File 'lib/route_guard/models/issue.rb', line 8 def initialize(rule_name:, severity:, message:, route:, related_routes: [], file: nil, line: nil) @rule_name = rule_name.to_sym @severity = severity.to_sym # :error, :warning @message = @route = route @related_routes = Array() @file = file || route&.file @line = line || route&.line end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
6 7 8 |
# File 'lib/route_guard/models/issue.rb', line 6 def file @file end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
6 7 8 |
# File 'lib/route_guard/models/issue.rb', line 6 def line @line end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/route_guard/models/issue.rb', line 6 def @message end |
#related_routes ⇒ Object (readonly)
Returns the value of attribute related_routes.
6 7 8 |
# File 'lib/route_guard/models/issue.rb', line 6 def @related_routes end |
#route ⇒ Object (readonly)
Returns the value of attribute route.
6 7 8 |
# File 'lib/route_guard/models/issue.rb', line 6 def route @route end |
#rule_name ⇒ Object (readonly)
Returns the value of attribute rule_name.
6 7 8 |
# File 'lib/route_guard/models/issue.rb', line 6 def rule_name @rule_name end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
6 7 8 |
# File 'lib/route_guard/models/issue.rb', line 6 def severity @severity end |
Instance Method Details
#location ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/route_guard/models/issue.rb', line 18 def location if file && line relative_file = file.sub(/\A#{Regexp.escape(Dir.pwd)}\//, "") "#{relative_file}:#{line}" elsif file file.sub(/\A#{Regexp.escape(Dir.pwd)}\//, "") else "unknown location" end end |