Class: DidYouMean::Experimental::IvarNameChecker
- Inherits:
-
Object
- Object
- DidYouMean::Experimental::IvarNameChecker
- Defined in:
- lib/did_you_mean/experimental/ivar_name_correction.rb
Overview
:nodoc:
Constant Summary collapse
- REPLS =
{ "(irb)" => -> { Readline::HISTORY.to_a.last } }
- TRACE =
TracePoint.trace(:raise) do |tp| e = tp.raised_exception if SPELL_CHECKERS.include?(e.class.to_s) && !e.instance_variable_defined?(:@frame_binding) e.instance_variable_set(:@frame_binding, tp.binding) end end
Instance Attribute Summary collapse
-
#original_checker ⇒ Object
readonly
Returns the value of attribute original_checker.
Instance Method Summary collapse
- #corrections ⇒ Object
-
#initialize(no_method_error, original_checker:) ⇒ IvarNameChecker
constructor
A new instance of IvarNameChecker.
- #ivar_name_corrections ⇒ Object
Constructor Details
#initialize(no_method_error, original_checker:) ⇒ IvarNameChecker
Returns a new instance of IvarNameChecker.
34 35 36 37 38 39 |
# File 'lib/did_you_mean/experimental/ivar_name_correction.rb', line 34 def initialize(no_method_error, original_checker: ) @original_checker = original_checker.new(no_method_error) @location = no_method_error.backtrace_locations.first @ivar_names = no_method_error.frame_binding.receiver.instance_variables end |
Instance Attribute Details
#original_checker ⇒ Object (readonly)
Returns the value of attribute original_checker.
32 33 34 |
# File 'lib/did_you_mean/experimental/ivar_name_correction.rb', line 32 def original_checker @original_checker end |
Instance Method Details
#corrections ⇒ Object
41 42 43 |
# File 'lib/did_you_mean/experimental/ivar_name_correction.rb', line 41 def corrections original_checker.corrections + ivar_name_corrections end |
#ivar_name_corrections ⇒ Object
45 46 47 |
# File 'lib/did_you_mean/experimental/ivar_name_correction.rb', line 45 def ivar_name_corrections @ivar_name_corrections ||= SpellChecker.new(dictionary: @ivar_names).correct(receiver_name.to_s) end |