Class: BELParser::Script::Syntax::UndefinedAnnotationError

Inherits:
Language::Syntax::SyntaxError show all
Defined in:
lib/bel_parser/script/syntax/undefined_annotation.rb

Overview

UndefinedAnnotationError represents an undefined annotation seen when checking a SET annotation.

Instance Attribute Summary collapse

Attributes inherited from Language::Syntax::SyntaxResult

#expression_node, #specification

Instance Method Summary collapse

Methods inherited from Language::Syntax::SyntaxError

#failure?, #success?, #to_s

Methods inherited from Language::Syntax::SyntaxResult

#failure?, #success?, #to_s

Constructor Details

#initialize(set_node, prefix, annotation_definitions) ⇒ UndefinedAnnotationError

Returns a new instance of UndefinedAnnotationError.



39
40
41
42
43
# File 'lib/bel_parser/script/syntax/undefined_annotation.rb', line 39

def initialize(set_node, prefix, annotation_definitions)
  super(set_node, nil)
  @prefix                 = prefix
  @annotation_definitions = annotation_definitions
end

Instance Attribute Details

#prefixObject (readonly)

Gets the undefined prefix.



37
38
39
# File 'lib/bel_parser/script/syntax/undefined_annotation.rb', line 37

def prefix
  @prefix
end

Instance Method Details

#msgObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/bel_parser/script/syntax/undefined_annotation.rb', line 45

def msg
  defined_annotations =
    if @annotation_definitions.empty?
      'No annotations are defined.'
    else
      annotation_prefixes = @annotation_definitions.keys.join(', ')
      "Defined annotations: #{annotation_prefixes}"
    end
  <<-MSG.gsub(/^ +/, '').delete("\n")
    Annotation definition is missing for "#@prefix". 
    #{defined_annotations}
  MSG
end