Class: Rigor::Analysis::Diagnostic

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/analysis/diagnostic.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, line:, column:, message:, severity: :error) ⇒ Diagnostic

Returns a new instance of Diagnostic.



8
9
10
11
12
13
14
# File 'lib/rigor/analysis/diagnostic.rb', line 8

def initialize(path:, line:, column:, message:, severity: :error)
  @path = path
  @line = line
  @column = column
  @message = message
  @severity = severity
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



6
7
8
# File 'lib/rigor/analysis/diagnostic.rb', line 6

def column
  @column
end

#lineObject (readonly)

Returns the value of attribute line.



6
7
8
# File 'lib/rigor/analysis/diagnostic.rb', line 6

def line
  @line
end

#messageObject (readonly)

Returns the value of attribute message.



6
7
8
# File 'lib/rigor/analysis/diagnostic.rb', line 6

def message
  @message
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/rigor/analysis/diagnostic.rb', line 6

def path
  @path
end

#severityObject (readonly)

Returns the value of attribute severity.



6
7
8
# File 'lib/rigor/analysis/diagnostic.rb', line 6

def severity
  @severity
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/rigor/analysis/diagnostic.rb', line 16

def error?
  severity == :error
end

#to_hObject



20
21
22
23
24
25
26
27
28
# File 'lib/rigor/analysis/diagnostic.rb', line 20

def to_h
  {
    "path" => path,
    "line" => line,
    "column" => column,
    "severity" => severity.to_s,
    "message" => message
  }
end

#to_sObject



30
31
32
# File 'lib/rigor/analysis/diagnostic.rb', line 30

def to_s
  "#{path}:#{line}:#{column}: #{severity}: #{message}"
end