class BELParser::Language::Semantics::SemanticEncodingOf

AST node for EncodingOf is a semantic AST.

Public Class Methods

new(encodings, **properties) click to toggle source
# File lib/bel_parser/language/semantics_ast.rb, line 609
def initialize(encodings, **properties)
  super(:encoding_of, encodings, properties)
end

Public Instance Methods

match(value_node, spec, will_match_partial = false) click to toggle source
# File lib/bel_parser/language/semantics_ast.rb, line 617
def match(value_node, spec, will_match_partial = false)
  unless value_node.respond_to?(:encoding) && value_node.encoding
    return invalid_encoding_warning(value_node, spec, match_encoding)
  end

  input     = value_node.encoding
  match     = match_encoding
  enc_match = input.product(match).any? do |(value_enc, match_enc)|
    value_enc.subtype_of?(match_enc)
  end

  if enc_match
    success(value_node, spec)
  else
    invalid_encoding_warning(value_node, spec, match_encoding)
  end
end
match_encoding() click to toggle source
# File lib/bel_parser/language/semantics_ast.rb, line 613
def match_encoding
  children
end