Exception: Ergane::CommandNotFound
- Defined in:
- lib/ergane/errors.rb
Instance Attribute Summary collapse
-
#available ⇒ Object
readonly
Returns the value of attribute available.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(token, available: []) ⇒ CommandNotFound
constructor
A new instance of CommandNotFound.
Constructor Details
#initialize(token, available: []) ⇒ CommandNotFound
Returns a new instance of CommandNotFound.
9 10 11 12 13 14 15 16 17 |
# File 'lib/ergane/errors.rb', line 9 def initialize(token, available: []) @token = token @available = available suggestion = find_suggestion msg = "Unknown command: '#{token}'" msg += ". Did you mean '#{suggestion}'?" if suggestion msg += "\nAvailable commands: #{available.join(', ')}" if available.any? super(msg) end |
Instance Attribute Details
#available ⇒ Object (readonly)
Returns the value of attribute available.
7 8 9 |
# File 'lib/ergane/errors.rb', line 7 def available @available end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
7 8 9 |
# File 'lib/ergane/errors.rb', line 7 def token @token end |