class TFClient::CommandParser

Constants

DIRECTION_MAP

Attributes

command[R]

0: 315 degrees, X=-1, Y=-1 (northwest) 1: 0 degrees, X=0, Y=-1 (north) 2: 45 degrees, X=1, Y=-1 (northeast) 3: 270 degrees, X=-1, Y=0 (west) 4: 90 degrees, X=1, Y=0 (east) 5: 225 degrees, X=-1, Y=1 (southwest) 6: 180 degrees, X=0, Y=-1 (south) 7: 135 degrees, X=1, Y=-1 (southeast)

Public Class Methods

new(command:) click to toggle source
# File lib/textflight-client/command_parser.rb, line 25
def initialize(command:)
  @command = command
end

Public Instance Methods

parse() click to toggle source
# File lib/textflight-client/command_parser.rb, line 29
def parse
  if @command == "quit" || @command == "exit"
    return "exit"
  end

  direction = DIRECTION_MAP[@command.to_sym]
  if direction
    "jump #{direction}"
  else
    @command
  end
end