Class: Polyglot::ValidationError

Inherits:
Object
  • Object
show all
Defined in:
lib/polyglot/validation_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#codeObject (readonly)

Returns the value of attribute code.



29
30
31
# File 'lib/polyglot/validation_result.rb', line 29

def code
  @code
end

#columnObject (readonly)

Returns the value of attribute column.



29
30
31
# File 'lib/polyglot/validation_result.rb', line 29

def column
  @column
end

#lineObject (readonly)

Returns the value of attribute line.



29
30
31
# File 'lib/polyglot/validation_result.rb', line 29

def line
  @line
end

#messageObject (readonly)

Returns the value of attribute message.



29
30
31
# File 'lib/polyglot/validation_result.rb', line 29

def message
  @message
end

#severityObject (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

Returns:



39
40
41
# File 'lib/polyglot/validation_result.rb', line 39

def error?
  @severity == "error"
end

#inspectObject



57
58
59
# File 'lib/polyglot/validation_result.rb', line 57

def inspect
  "#<Polyglot::ValidationError #{@severity}: #{@message}>"
end

#to_hObject



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

Returns:



43
44
45
# File 'lib/polyglot/validation_result.rb', line 43

def warning?
  @severity == "warning"
end