Class: BELParser::Language::Semantics::RelationshipNotMultipleWarning

Inherits:
SemanticsWarning show all
Defined in:
lib/bel_parser/language/semantics/relationship_not_listable.rb

Overview

Represents a SemanticsWarning when a statement has a relationship that cannot reference multiple objects.

Instance Attribute Summary

Attributes inherited from SemanticsResult

#expression_node, #specification

Instance Method Summary collapse

Methods inherited from SemanticsWarning

#failure?, #success?

Methods inherited from SemanticsResult

#failure?, #msg, #success?

Constructor Details

#initialize(statement_node, spec, rel) ⇒ RelationshipNotMultipleWarning

Returns a new instance of RelationshipNotMultipleWarning.



42
43
44
45
# File 'lib/bel_parser/language/semantics/relationship_not_listable.rb', line 42

def initialize(statement_node, spec, rel)
  super(statement_node, spec)
  @rel = rel
end

Instance Method Details

#to_sObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/bel_parser/language/semantics/relationship_not_listable.rb', line 47

def to_s
  multiple_relationships =
    @specification
    .listable_relationships
    .map(&:long)
    .join(', ')
  <<-MSG.gsub(/ {12}/, '').strip
    Statement must use a multiple relationship with a list object.
      The "#{@rel.long}" relationship cannot reference multiple objects.
      Multiple Relationships: #{multiple_relationships}
  MSG
end