module Gamefic::Scanner
A module for matching objects to tokens.
Constants
- DEFAULT_PROCESSORS
Public Class Methods
processors()
click to toggle source
@return [Array<Class<Base>>]
# File lib/gamefic/scanner.rb, line 44 def self.processors @processors ||= [] end
scan(selection, token)
click to toggle source
Scan entities against a token.
@param selection [Array<Entity>] @param token [String] @return [Result]
# File lib/gamefic/scanner.rb, line 21 def self.scan selection, token result = nil processors.each do |processor| result = processor.scan(selection, token) break unless result.matched.empty? end result end
strictness(processor)
click to toggle source
# File lib/gamefic/scanner.rb, line 48 def self.strictness processor (processors.length - (processors.find_index(processor) || processors.length)) * 100 end
use(*klasses)
click to toggle source
Select the scanner processors to use in entity queries. Each processor will be used in order until one of them returns matches. The default processor list is ‘DEFAULT_PROCESSORS`.
Processor classes should be in order from most to least strict rules for matching tokens to entities.
@param klasses [Array<Class<Base>>] @return [Array<Class<Base>>]
# File lib/gamefic/scanner.rb, line 39 def self.use *klasses processors.replace klasses.flatten end