class Gamefic::Scanner::Nesting
Strict
scanning for entities inside of other entities, e.g., ‘sock inside drawer`.
Constants
- NEST_REGEXP
Public Instance Methods
Source
# File lib/gamefic/scanner/nesting.rb, line 14 def scan return unmatched_result unless token =~ NEST_REGEXP denest end
Private Instance Methods
Source
# File lib/gamefic/scanner/nesting.rb, line 22 def denest near = selection far = selection 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 & selection far = last_result.matched.first.flatten & selection end last_result end