Module: Jade::DidYouMean

Extended by:
DidYouMean
Included in:
DidYouMean
Defined in:
lib/jade/did_you_mean.rb

Instance Method Summary collapse

Instance Method Details

#suggest(name, candidates, max: 3) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/jade/did_you_mean.rb', line 7

def suggest(name, candidates, max: 3)
  return [] if name.nil? || candidates.empty?

  ::DidYouMean::SpellChecker
    .new(dictionary: candidates.uniq)
    .correct(name)
    .first(max)
end