Sha256: 3fe92dceeaf6423e34769a9642e88d94fb52f934519d5959194415e08c9a2f81

Contents?: true

Size: 680 Bytes

Versions: 7

Compression:

Stored size: 680 Bytes

Contents

# frozen_string_literal: true

require_relative "../exceptions_base"

module Exceptions
  module NameError
    class UndefinedVariable < 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
        store.transaction { |s| s[pry_instance_uid] }
      end

      def exception_regexp
        /`(\w+)'/
      end

      # Use the current binding identifier as pry instance uid.
      def pry_instance_uid
        pry.current_binding.to_s
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pry-byetypo-1.3.5 lib/pry-byetypo/exceptions/name_error/undefined_variable.rb
pry-byetypo-1.3.4 lib/pry-byetypo/exceptions/name_error/undefined_variable.rb
pry-byetypo-1.3.3 lib/pry-byetypo/exceptions/name_error/undefined_variable.rb
pry-byetypo-1.3.2 lib/pry-byetypo/exceptions/name_error/undefined_variable.rb
pry-byetypo-1.3.1 lib/pry-byetypo/exceptions/name_error/undefined_variable.rb
pry-byetypo-1.3.0 lib/pry-byetypo/exceptions/name_error/undefined_variable.rb
pry-byetypo-1.2.0 lib/pry-byetypo/exceptions/name_error/undefined_variable.rb