Class: Polyglot::ValidationError
- Inherits:
-
Object
- Object
- Polyglot::ValidationError
- Defined in:
- lib/polyglot/validation_result.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(data) ⇒ ValidationError
constructor
A new instance of ValidationError.
- #inspect ⇒ Object
- #to_h ⇒ Object
- #warning? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ ValidationError
Returns a new instance of ValidationError.
31 32 33 34 35 36 37 |
# File 'lib/polyglot/validation_result.rb', line 31 def initialize(data) @message = data["message"] @line = data["line"] @column = data["column"] @severity = data["severity"] @code = data["code"] end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
29 30 31 |
# File 'lib/polyglot/validation_result.rb', line 29 def code @code end |
#column ⇒ Object (readonly)
Returns the value of attribute column.
29 30 31 |
# File 'lib/polyglot/validation_result.rb', line 29 def column @column end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
29 30 31 |
# File 'lib/polyglot/validation_result.rb', line 29 def line @line end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
29 30 31 |
# File 'lib/polyglot/validation_result.rb', line 29 def @message end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
29 30 31 |
# File 'lib/polyglot/validation_result.rb', line 29 def severity @severity end |
Instance Method Details
#error? ⇒ Boolean
39 40 41 |
# File 'lib/polyglot/validation_result.rb', line 39 def error? @severity == "error" end |
#inspect ⇒ Object
57 58 59 |
# File 'lib/polyglot/validation_result.rb', line 57 def inspect "#<Polyglot::ValidationError #{@severity}: #{@message}>" end |
#to_h ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/polyglot/validation_result.rb', line 47 def to_h { message: @message, line: @line, column: @column, severity: @severity, code: @code } end |
#warning? ⇒ Boolean
43 44 45 |
# File 'lib/polyglot/validation_result.rb', line 43 def warning? @severity == "warning" end |