Class: Gamefic::Scanner::Fuzzy

Inherits:
Strict show all
Defined in:
lib/gamefic/scanner/fuzzy.rb

Overview

Fuzzy token matching.

An entity will match a word in a fuzzy scan if it matches the beginning of one of the entity’s keywords, e.g., ‘pen` is a fuzzy token match for the keyword `pencil`.

Instance Attribute Summary

Attributes inherited from Base

#selection, #token

Instance Method Summary collapse

Methods inherited from Strict

#scan

Methods inherited from Base

#initialize, #scan, scan

Constructor Details

This class inherits a constructor from Gamefic::Scanner::Base

Instance Method Details

#match_word(available, word) ⇒ Object



12
13
14
# File 'lib/gamefic/scanner/fuzzy.rb', line 12

def match_word available, word
  available.select { |obj| obj.keywords.any? { |wrd| wrd.start_with?(word) } }
end