Class: DidYouMean::NameFinder

Inherits:
Object
  • Object
show all
Includes:
BaseFinder
Defined in:
lib/did_you_mean/finders/name_error_finders/name_finder.rb

Constant Summary

Constants included from BaseFinder

BaseFinder::AT, BaseFinder::EMPTY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseFinder

#suggestions

Constructor Details

#initialize(exception) ⇒ NameFinder

Returns a new instance of NameFinder.



6
7
8
9
10
11
12
# File 'lib/did_you_mean/finders/name_error_finders/name_finder.rb', line 6

def initialize(exception)
  @name         = exception.name.to_s.tr(AT, EMPTY)
  @lvar_names   = exception.frame_binding.eval("local_variables")
  @method_names = exception.frame_binding.eval("methods + private_methods")
  @cvar_names   = exception.frame_binding.eval("self.class.class_variables")
  @ivar_names   = exception.frame_binding.eval("instance_variables")
end

Instance Attribute Details

#cvar_namesObject (readonly)

Returns the value of attribute cvar_names.



4
5
6
# File 'lib/did_you_mean/finders/name_error_finders/name_finder.rb', line 4

def cvar_names
  @cvar_names
end

#ivar_namesObject (readonly)

Returns the value of attribute ivar_names.



4
5
6
# File 'lib/did_you_mean/finders/name_error_finders/name_finder.rb', line 4

def ivar_names
  @ivar_names
end

#lvar_namesObject (readonly)

Returns the value of attribute lvar_names.



4
5
6
# File 'lib/did_you_mean/finders/name_error_finders/name_finder.rb', line 4

def lvar_names
  @lvar_names
end

#method_namesObject (readonly)

Returns the value of attribute method_names.



4
5
6
# File 'lib/did_you_mean/finders/name_error_finders/name_finder.rb', line 4

def method_names
  @method_names
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/did_you_mean/finders/name_error_finders/name_finder.rb', line 4

def name
  @name
end

Instance Method Details

#searchesObject



14
15
16
# File 'lib/did_you_mean/finders/name_error_finders/name_finder.rb', line 14

def searches
  {name => (lvar_names + method_names + ivar_names + cvar_names)}
end