Module: LocoBot::Robot::Direction

Defined in:
lib/loco_bot/robot/direction.rb,
lib/loco_bot/robot/direction/east.rb,
lib/loco_bot/robot/direction/west.rb,
lib/loco_bot/robot/direction/north.rb,
lib/loco_bot/robot/direction/south.rb

Overview

Top-level namespace for the possible facing directions.

Defined Under Namespace

Modules: East, North, South, West

Class Method Summary collapse

Class Method Details

.from_name(name) ⇒ Command

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

Parameters:

  • name (String)

    the Direction name

Returns:

  • (Command)

    the Direction



19
20
21
# File 'lib/loco_bot/robot/direction.rb', line 19

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

.listArray<String>

Returns the list of available Direction as Strings.

Returns:

  • (Array<String>)


12
13
14
# File 'lib/loco_bot/robot/direction.rb', line 12

def self.list
  constants.map(&:to_s)
end