module CommandHelper
CommandHelper
contains all the helper methods to valid integrity and type of a command
Public Instance Methods
a_valid_place_command?(command)
click to toggle source
it will validate the provided command against the PLACE_COMMAND_PATTERN set in the application_contants @retrun [Boolean]
# File lib/helpers/command_helper.rb, line 9 def a_valid_place_command?(command) return false if command.match(PLACE_COMMAND_PATTERN).nil? true end
command_type(command)
click to toggle source
it will return type of command such as PLACE, MOVE, LEFT, RIGHT, REPORT @return [String]
# File lib/helpers/command_helper.rb, line 22 def command_type(command) return if command.nil? return PLACE if command.include? PLACE return command if COMMANDS.include? command end
commands()
click to toggle source
return all valid commands array [MOVE LEFT RIGHT REPORT PLACE] @return [Array]
# File lib/helpers/command_helper.rb, line 36 def commands COMMANDS end
directions()
click to toggle source
return all directions array [NORTH EAST SOUTH WEST] @return [Array]
# File lib/helpers/command_helper.rb, line 30 def directions DIRECTIONS end
split_place_command(place_command)
click to toggle source
# File lib/helpers/command_helper.rb, line 15 def split_place_command(place_command) result = place_command.match(PLACE_COMMAND_PATTERN) result&.captures end