Class: RubyPitaya::ParameterMissing::Correction

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/core/parameters.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rubypitaya-3.12.1/lib/rubypitaya/core/parameters.rb

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ Correction

Returns a new instance of Correction.



22
23
24
# File 'lib/rubypitaya/core/parameters.rb', line 22

def initialize(error)
  @error = error
end

Instance Method Details

#correctionsObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rubypitaya/core/parameters.rb', line 26

def corrections
  if @error.param && @error.keys
    maybe_these = @error.keys

    maybe_these.sort_by { |n|
      DidYouMean::Jaro.distance(@error.param.to_s, n)
    }.reverse.first(4)
  else
    []
  end
end