Class: BELParser::Script::State::AnnotationDefinition

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

Constant Summary collapse

TARGET_NODE =
BELParser::Parsers::AST::AnnotationDefinition

Class Method Summary collapse

Methods included from BELParser::Script::StateFunction

consume

Class Method Details

.consume(ast_node, script_context) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bel_parser/script/state/annotation_definition.rb', line 15

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
  prefix          = keyword.identifier.string_literal
  case
  when domain.list?
    handle_list(prefix, domain.child, script_context)
  when domain.uri?
    uri = domain.child.string.string_literal
    handle_uri(prefix, uri, script_context)
  when domain.url?
    ApplyResourceURI.new.process(ast_node)
    if ast_node.uri
      handle_uri(prefix, ast_node.uri, script_context)
    else
      url = domain.child.string.string_literal
      handle_url(prefix, url, script_context)
    end
  when domain.pattern?
    handle_pattern(prefix, domain.child, script_context)
  end
end