Class: ClasslessMud::Commands::BadCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/classless_mud/commands/bad_command.rb

Defined Under Namespace

Classes: Suggestions

Class Method Summary collapse

Class Method Details

.matches(message) ⇒ Object



15
16
17
18
# File 'lib/classless_mud/commands/bad_command.rb', line 15

def self.matches message
  Suggestions.new(message.split(' ').first)
             .matches(ClasslessMud::Commands::Commands.commands)
end

.perform(game, player, message) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/classless_mud/commands/bad_command.rb', line 4

def self.perform game, player, message
  if matches(message).any?
    player.puts "Did you mean:\n  \#{matches(message).join(' ')}\n"
  else
    player.puts 'You typed that wrong. Try again.'
  end
end