Class: ArchUnit::Common::Extraction::ParseDiagnostic

Inherits:
Data
  • Object
show all
Defined in:
lib/archunit/common/extraction/parse_diagnostic.rb

Overview

Immutable parser failure location; line and column are both one-based.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, line:, column:, message:) ⇒ ParseDiagnostic

Returns a new instance of ParseDiagnostic.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/archunit/common/extraction/parse_diagnostic.rb', line 8

def initialize(path:, line:, column:, message:)
  unless [path, message].all? { |value| value.is_a?(String) && !value.empty? }
    raise ArgumentError, 'parse diagnostic requires a non-empty path and message'
  end
  unless [line, column].all? { |value| value.is_a?(Integer) && value.positive? }
    raise ArgumentError, 'parse diagnostic coordinates must be positive integers'
  end

  path = path.tr('\\', '/').freeze
  message = message.dup.freeze
  super
end

Instance Attribute Details

#column ⇒ Object (readonly)

Returns the value of attribute column

Returns:

  • (Object) —

    the current value of column



7
8
9
# File 'lib/archunit/common/extraction/parse_diagnostic.rb', line 7

def column
  @column
end

#line ⇒ Object (readonly)

Returns the value of attribute line

Returns:

  • (Object) —

    the current value of line



7
8
9
# File 'lib/archunit/common/extraction/parse_diagnostic.rb', line 7

def line
  @line
end

#message ⇒ Object (readonly)

Returns the value of attribute message

Returns:

  • (Object) —

    the current value of message



7
8
9
# File 'lib/archunit/common/extraction/parse_diagnostic.rb', line 7

def message
  @message
end

#path ⇒ Object (readonly)

Returns the value of attribute path

Returns:

  • (Object) —

    the current value of path



7
8
9
# File 'lib/archunit/common/extraction/parse_diagnostic.rb', line 7

def path
  @path
end