class Gamefic::Scanner::Nesting
Strict
scanning for entities inside of other entities, e.g., ‘sock inside drawer`.
Constants
- NEST_REGEXP
Public Instance Methods
scan()
click to toggle source
# File lib/gamefic/scanner/nesting.rb, line 14 def scan return unmatched_result unless token =~ NEST_REGEXP denest selection, token end
subprocessor()
click to toggle source
# File lib/gamefic/scanner/nesting.rb, line 10 def subprocessor Strict end
Private Instance Methods
denest(objects, token)
click to toggle source
# File lib/gamefic/scanner/nesting.rb, line 22 def denest objects, token near = objects far = objects parts = token.split(NEST_REGEXP) until parts.empty? current = parts.pop last_result = subprocessor.scan(near, current) last_result = subprocessor.scan(far, current) if last_result.matched.empty? && near != far return unmatched_result if last_result.matched.empty? || last_result.matched.length > 1 near = last_result.matched.first.children & objects far = last_result.matched.first.flatten & objects end last_result end