Class: Glossarist::Validation::ValidationIssue
- Inherits:
-
Object
- Object
- Glossarist::Validation::ValidationIssue
- Defined in:
- lib/glossarist/validation/validation_issue.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#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
- #error? ⇒ Boolean
- #info? ⇒ Boolean
-
#initialize(severity:, message:, code: nil, location: nil, suggestion: nil) ⇒ ValidationIssue
constructor
A new instance of ValidationIssue.
- #to_s ⇒ Object
- #warning? ⇒ Boolean
Constructor Details
#initialize(severity:, message:, code: nil, location: nil, suggestion: nil) ⇒ ValidationIssue
Returns a new instance of ValidationIssue.
8 9 10 11 12 13 14 15 |
# File 'lib/glossarist/validation/validation_issue.rb', line 8 def initialize(severity:, message:, code: nil, location: nil, suggestion: nil) @severity = severity @code = code @message = @location = location @suggestion = suggestion end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/glossarist/validation/validation_issue.rb', line 6 def code @code end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
6 7 8 |
# File 'lib/glossarist/validation/validation_issue.rb', line 6 def location @location end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/glossarist/validation/validation_issue.rb', line 6 def @message end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
6 7 8 |
# File 'lib/glossarist/validation/validation_issue.rb', line 6 def severity @severity end |
#suggestion ⇒ Object (readonly)
Returns the value of attribute suggestion.
6 7 8 |
# File 'lib/glossarist/validation/validation_issue.rb', line 6 def suggestion @suggestion end |
Instance Method Details
#error? ⇒ Boolean
17 18 19 |
# File 'lib/glossarist/validation/validation_issue.rb', line 17 def error? severity == "error" end |
#info? ⇒ Boolean
25 26 27 |
# File 'lib/glossarist/validation/validation_issue.rb', line 25 def info? severity == "info" end |
#to_s ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/glossarist/validation/validation_issue.rb', line 29 def to_s parts = ["[#{severity.upcase}]"] parts << "[#{code}]" if code parts << (location ? "#{location}: " : "") parts << parts << " (#{suggestion})" if suggestion parts.join(" ") end |
#warning? ⇒ Boolean
21 22 23 |
# File 'lib/glossarist/validation/validation_issue.rb', line 21 def warning? severity == "warning" end |