Class: Gemfilelint::SpellChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/gemfilelint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(haystack) ⇒ SpellChecker

Returns a new instance of SpellChecker.



15
16
17
18
# File 'lib/gemfilelint.rb', line 15

def initialize(haystack)
  @detector = Bundler::SimilarityDetector.new(haystack)
  @haystack = haystack
end

Instance Attribute Details

#detectorObject (readonly)

Returns the value of attribute detector.



13
14
15
# File 'lib/gemfilelint.rb', line 13

def detector
  @detector
end

#haystackObject (readonly)

Returns the value of attribute haystack.



13
14
15
# File 'lib/gemfilelint.rb', line 13

def haystack
  @haystack
end

Instance Method Details

#correct(needle) ⇒ Object



20
21
22
23
24
# File 'lib/gemfilelint.rb', line 20

def correct(needle)
  return [] if haystack.include?(needle)

  detector.similar_words(needle, 2)
end