Sha256: edabdf02b5aa7a0cc26fa9223c65b1df6c658e27a6e09defdcc33abfce6376da

Contents?: true

Size: 580 Bytes

Versions: 2

Compression:

Stored size: 580 Bytes

Contents

# frozen_string_literal: true

require_relative "exceptions_base"

module Exceptions
  class NoMethodError < ExceptionsBase
    private

    def corrected_cmd
      @corrected_cmd ||= last_cmd.gsub(/\b#{unknown_from_exception}\b/, corrected_word)
    end

    def unknown_from_exception
      exception.to_s.match(exception_regexp)[1]
    end

    def dictionary
      eval(klass).methods.map(&:to_s) # rubocop:disable Security/Eval
    end

    def exception_regexp
      /`([^']+)' for/
    end

    def klass
      exception.to_s.match(/for\s+(.*?):\w*$/)[1]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pry-byetypo-1.3.1 lib/pry-byetypo/exceptions/no_method_error.rb
pry-byetypo-1.3.0 lib/pry-byetypo/exceptions/no_method_error.rb