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_bel, #to_s, #to_sexp, #updated

Methods included from Parsers

#serialize

Constructor Details

#initialize(mod_types, **properties) ⇒ SemanticCovalentProteinModificationOf

Returns a new instance of SemanticCovalentProteinModificationOf.



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

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



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

def covalent_protein_modification_types
  children
end

#match(value_node, spec, will_match_partial = false) ⇒ Object



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

def match(value_node, spec, will_match_partial = false)
  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