Class: Uniword::Quality::QualityViolation
- Inherits:
-
Object
- Object
- Uniword::Quality::QualityViolation
- Defined in:
- lib/uniword/quality/quality_rule.rb
Overview
Represents a quality violation found in a document
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
Instance Method Summary collapse
-
#error? ⇒ Boolean
Check if violation is an error.
-
#info? ⇒ Boolean
Check if violation is info.
-
#initialize(rule:, severity:, message:, location:, element: nil) ⇒ QualityViolation
constructor
Initialize violation.
-
#to_h ⇒ Hash
Convert violation to hash.
-
#warning? ⇒ Boolean
Check if violation is a warning.
Constructor Details
#initialize(rule:, severity:, message:, location:, element: nil) ⇒ QualityViolation
Initialize violation
95 96 97 98 99 100 101 102 103 |
# File 'lib/uniword/quality/quality_rule.rb', line 95 def initialize(rule:, severity:, message:, location:, element: nil) @rule = rule @severity = severity @message = @location = location @element = element validate_severity! end |
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
86 87 88 |
# File 'lib/uniword/quality/quality_rule.rb', line 86 def element @element end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
86 87 88 |
# File 'lib/uniword/quality/quality_rule.rb', line 86 def location @location end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
86 87 88 |
# File 'lib/uniword/quality/quality_rule.rb', line 86 def @message end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
86 87 88 |
# File 'lib/uniword/quality/quality_rule.rb', line 86 def rule @rule end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
86 87 88 |
# File 'lib/uniword/quality/quality_rule.rb', line 86 def severity @severity end |
Instance Method Details
#error? ⇒ Boolean
Check if violation is an error
108 109 110 |
# File 'lib/uniword/quality/quality_rule.rb', line 108 def error? severity == :error end |
#info? ⇒ Boolean
Check if violation is info
122 123 124 |
# File 'lib/uniword/quality/quality_rule.rb', line 122 def info? severity == :info end |
#to_h ⇒ Hash
Convert violation to hash
129 130 131 132 133 134 135 136 |
# File 'lib/uniword/quality/quality_rule.rb', line 129 def to_h { rule: rule, severity: severity, message: , location: location, } end |
#warning? ⇒ Boolean
Check if violation is a warning
115 116 117 |
# File 'lib/uniword/quality/quality_rule.rb', line 115 def warning? severity == :warning end |