Class: BELParser::Script::State::DocumentProperty

Inherits:
Object
  • Object
show all
Extended by:
BELParser::Script::StateFunction
Defined in:
lib/bel_parser/script/state/document_property.rb

Constant Summary collapse

TARGET_NODE =
BELParser::Parsers::AST::DocumentProperty

Class Method Summary collapse

Methods included from BELParser::Script::StateFunction

consume

Class Method Details

.consume(ast_node, script_context) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# 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