class BELParser::Script::State::NamespaceDefinition
Constants
- TARGET_NODE
AST
node representing the definition of a namespace.
Public Class Methods
consume(ast_node, script_context)
click to toggle source
# File lib/bel_parser/script/state/namespace_definition.rb, line 16 def self.consume(ast_node, script_context) return nil unless ast_node.is_a?(TARGET_NODE) uri_reader = script_context[:uri_reader] url_reader = script_context[:url_reader] keyword, domain = ast_node.children keyword_s = keyword.identifier.string_literal case when domain.uri? uri = domain.child.string.string_literal dataset = uri_reader.retrieve_resource(uri) script_context[:namespace_definitions] ||= Concurrent::Hash.new script_context[:namespace_definitions][keyword_s] = BELParser::Expression::Model::Namespace.new( keyword_s, uri, nil) when domain.url? ApplyResourceURI.new.process(ast_node) if ast_node.uri dataset = uri_reader.retrieve_resource(ast_node.uri) script_context[:namespace_definitions] ||= Concurrent::Hash.new script_context[:namespace_definitions][keyword_s] = BELParser::Expression::Model::Namespace.new( keyword_s, ast_node.uri, domain.child.string.string_literal) else url = domain.child.string.string_literal dataset = url_reader.retrieve_resource(url) script_context[:namespace_definitions] ||= Concurrent::Hash.new script_context[:namespace_definitions][keyword_s] = BELParser::Expression::Model::Namespace.new( keyword_s, nil, url) end end end