Class: Gemfilelint::SpellChecker
- Inherits:
-
Object
- Object
- Gemfilelint::SpellChecker
- Defined in:
- lib/gemfilelint.rb
Instance Attribute Summary collapse
-
#detector ⇒ Object
readonly
Returns the value of attribute detector.
-
#haystack ⇒ Object
readonly
Returns the value of attribute haystack.
Instance Method Summary collapse
- #correct(needle) ⇒ Object
-
#initialize(haystack) ⇒ SpellChecker
constructor
A new instance of SpellChecker.
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
#detector ⇒ Object (readonly)
Returns the value of attribute detector.
13 14 15 |
# File 'lib/gemfilelint.rb', line 13 def detector @detector end |
#haystack ⇒ Object (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 |