Class: SyntaxTree::BasicVisitor::VisitMethodChecker

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

Overview

This class is used by DidYouMean to offer corrections to invalid visit method names.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ VisitMethodChecker

Returns a new instance of VisitMethodChecker.



25
26
27
# File 'lib/syntax_tree/basic_visitor.rb', line 25

def initialize(error)
  @visit_method = error.visit_method
end

Instance Attribute Details

#visit_methodObject (readonly)

Returns the value of attribute visit_method.



23
24
25
# File 'lib/syntax_tree/basic_visitor.rb', line 23

def visit_method
  @visit_method
end

Instance Method Details

#correctionsObject



29
30
31
32
33
34
# File 'lib/syntax_tree/basic_visitor.rb', line 29

def corrections
  @corrections ||=
    DidYouMean::SpellChecker.new(
      dictionary: BasicVisitor.valid_visit_methods
    ).correct(visit_method)
end