Class: BELParser::Language::Semantics::NonCausalNestedStatementWarning

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

Overview

Represents a SemanticsWarning when a nested Parsers::AST::Statement has a non-causal relationship.

Instance Attribute Summary collapse

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(stmt_node, spec, rel) ⇒ NonCausalNestedStatementWarning

Returns a new instance of NonCausalNestedStatementWarning.



30
31
32
33
# File 'lib/bel_parser/language/semantics/non_causal_nested_statement.rb', line 30

def initialize(stmt_node, spec, rel)
  super(stmt_node, spec)
  @non_causal_relationship = spec.relationship(rel)
end

Instance Attribute Details

#non_causal_relationshipObject (readonly)

Returns the value of attribute non_causal_relationship.



28
29
30
# File 'lib/bel_parser/language/semantics/non_causal_nested_statement.rb', line 28

def non_causal_relationship
  @non_causal_relationship
end

Instance Method Details

#to_sObject



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/bel_parser/language/semantics/non_causal_nested_statement.rb', line 35

def to_s
  causal_relationships =
    @specification
    .causal_relationships
    .map(&:long)
    .join(', ')
  <<-MSG.gsub(/ {12}/, '')
    Nested statement is not a causal relationship.
     The "#{non_causal_relationship.long}" relationship is not causal.
     Causal Relationships: #{causal_relationships}
  MSG
end