Module: LocoBot::CLI::Command

Defined in:
lib/loco_bot/cli/command.rb,
lib/loco_bot/cli/command/base.rb,
lib/loco_bot/cli/command/left.rb,
lib/loco_bot/cli/command/move.rb,
lib/loco_bot/cli/command/hodor.rb,
lib/loco_bot/cli/command/place.rb,
lib/loco_bot/cli/command/right.rb,
lib/loco_bot/cli/command/report.rb

Overview

Top-level namespace for available commands.

Defined Under Namespace

Classes: Base, Hodor, Left, Move, Place, Report, Right

Class Method Summary collapse

Class Method Details

.class_from_name(name) ⇒ Command

Returns a Command class that as the same name as the given name.


24
25
26
27
28
# File 'lib/loco_bot/cli/command.rb', line 24

def self.class_from_name(name)
  return nil if name.nil? || name.capitalize.to_s == 'Base'

  const_get(name.capitalize) if const_defined?(name.capitalize, false)
end

.listArray<String>

Returns the list of available commands.


15
16
17
18
19
# File 'lib/loco_bot/cli/command.rb', line 15

def self.list
  list = constants.map { |const| const.to_s.upcase }
  list.delete('BASE')
  list
end