Exception: Gem::UnknownCommandError

Inherits:
Exception
  • Object
show all
Defined in:
lib/rubygems/exceptions.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(unknown_command) ⇒ UnknownCommandError

Returns a new instance of UnknownCommandError.



16
17
18
19
20
21
# File 'lib/rubygems/exceptions.rb', line 16

def initialize(unknown_command)
  self.class.attach_correctable

  @unknown_command = unknown_command
  super("Unknown command #{unknown_command}")
end

Instance Attribute Details

#unknown_commandObject (readonly)

Returns the value of attribute unknown_command.



14
15
16
# File 'lib/rubygems/exceptions.rb', line 14

def unknown_command
  @unknown_command
end

Class Method Details

.attach_correctableObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rubygems/exceptions.rb', line 23

def self.attach_correctable
  return if defined?(@attached)

  if defined?(DidYouMean::SPELL_CHECKERS) && defined?(DidYouMean::Correctable)
    if DidYouMean.respond_to?(:correct_error)
      DidYouMean.correct_error(Gem::UnknownCommandError, Gem::UnknownCommandSpellChecker)
    else
      DidYouMean::SPELL_CHECKERS["Gem::UnknownCommandError"] =
        Gem::UnknownCommandSpellChecker

      prepend DidYouMean::Correctable
    end
  end

  @attached = true
end