Class: BELParser::Script::State::BELVersion
- Inherits:
-
Object
- Object
- BELParser::Script::State::BELVersion
- Extended by:
- Keyword, BELParser::Script::StateFunction
- Defined in:
- lib/bel_parser/script/state/bel_version.rb
Constant Summary collapse
- TARGET_NODE =
BELParser::Parsers::AST::DocumentProperty
- DEFAULT_BEL_VERSION =
'1.0'
Constants included from Keyword
Keyword::BEL_VERSION_REGEX, Keyword::BEL_VERSION_STRING, Keyword::CITATION, Keyword::CITATION_REGEX, Keyword::IMPLICIT_ANNOTATIONS, Keyword::SUPPORT, Keyword::SUPPORT_REGEX
Class Method Summary collapse
Methods included from BELParser::Script::StateFunction
Methods included from Keyword
is_bel_version?, is_citation?, is_implicit_annotation?, is_support?
Class Method Details
.consume(ast_node, script_context) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bel_parser/script/state/bel_version.rb', line 17 def self.consume(ast_node, script_context) return unless ast_node.is_a?(TARGET_NODE) name, value = ast_node.children name_string = name.identifier.string_literal return unless is_bel_version?(name_string) value_string = value.children[0].string_literal begin spec = BELParser::Language.specification(value_string) rescue ArgumentError spec = BELParser::Language.specification(DEFAULT_BEL_VERSION) end script_context[:specification] = spec end |