Class: BELParser::Language::Semantics::SemanticCovalentProteinModificationOf

Inherits:
SemanticASTNode show all
Defined in:
lib/bel_parser/language/semantics_ast.rb

Overview

AST node for CovalentProteinModificationOf is a semantic AST.

Instance Attribute Summary

Attributes inherited from AST::Node

#children, #hash, #type

Instance Method Summary collapse

Methods inherited from SemanticASTNode

#terminal?

Methods inherited from AST::Node

#==, #append, #concat, #dup, #eql?, #inspect, #to_a, #to_ast, #to_sexp, #updated

Constructor Details

#initialize(mod_types, **properties) ⇒ SemanticCovalentProteinModificationOf

Returns a new instance of SemanticCovalentProteinModificationOf.



688
689
690
691
# File 'lib/bel_parser/language/semantics_ast.rb', line 688

def initialize(mod_types, **properties)
  properties[:hashed] = Hash[mod_types.map { |t| [t, true] }]
  super(:covalent_protein_modification_of, mod_types, properties)
end

Instance Method Details

#covalent_protein_modification_typesObject



693
694
695
# File 'lib/bel_parser/language/semantics_ast.rb', line 693

def covalent_protein_modification_types
  children
end

#match(value_node, spec) ⇒ Object



697
698
699
700
701
702
703
704
705
706
707
708
709
# File 'lib/bel_parser/language/semantics_ast.rb', line 697

def match(value_node, spec)
  string_literal_sym = value_node.children[0].string_literal.to_sym
  return success(value_node, spec) if @hashed[:*]

  if @hashed.key?(string_literal_sym)
    success(value_node, spec)
  else
    invalid_protein_modification_warning(
      value_node,
      spec,
      @hashed.keys)
  end
end