Class: BEL::Completion::MatchFunctionRule
- Inherits:
-
Object
- Object
- BEL::Completion::MatchFunctionRule
- Includes:
- Rule
- Defined in:
- lib/bel/completion_rule.rb
Overview
MatchFunctionRule defines a function completion rule. This rule relies on a BELParser::Language::Specification for the available functions.
Instance Method Summary collapse
Methods included from Rule
Instance Method Details
#_apply(token_list, active_token, active_token_index, options = {}) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/bel/completion_rule.rb', line 109 def _apply(token_list, active_token, active_token_index, = {}) if token_list.empty? or active_token.type == :O_PAREN return spec_functions([:specification]).map(&method(:map_function)) end if active_token.type == :IDENT value = active_token.value.downcase matches = spec_functions([:specification]).select do |func| func.short.to_s.include?(value) || func.long.to_s.include?(value) end return matches.map(&method(:map_function)) end return EMPTY_MATCH end |