class BELParser::Script::State::DocumentProperty

Constants

TARGET_NODE

AST node representing a document property (e.g. +SET DOCUMENT …+).

Public Class Methods

consume(ast_node, script_context) click to toggle source
# File lib/bel_parser/script/state/document_property.rb, line 13
def self.consume(ast_node, script_context)
  return nil unless ast_node.is_a?(TARGET_NODE)
  hash = script_context[:document_properties] ||= Concurrent::Hash.new

  name, value = ast_node.children
  if name && value
    name_string  = name.identifier.string_literal
    value_string = value.children[0].string_literal
    hash[name_string] = value_string
  end
end