class Fontist::FormulaSuggestion
Constants
- MINIMUM_REQUIRED_SCORE
Public Class Methods
new()
click to toggle source
# File lib/fontist/formula_suggestion.rb, line 7 def initialize @fuzzy_match = prepare_search_engine end
Public Instance Methods
find(name)
click to toggle source
# File lib/fontist/formula_suggestion.rb, line 11 def find(name) @fuzzy_match.find_all_with_score(normalize(name)) .tap { |res| Fontist.ui.debug(prettify_result(res)) } .select { |_key, score, _| score >= MINIMUM_REQUIRED_SCORE } .take(10) .map(&:first) .map { |x| Formula.find_by_key_or_name(x) } .select(&:downloadable?) end