Class: Robot::Commands::Place
- Extended by:
- PlaceCommandParser
- Defined in:
- lib/robot/commands/place.rb
Overview
Place Command
Constant Summary collapse
- REGEX =
/^\A(PLACE) \d,\d,(NORTH|EAST|WEST|SOUTH)\z/.freeze
Class Method Summary collapse
- .build_from_string_command(command) ⇒ Object
- .call(x:, y:, f:) ⇒ Object
- .matches?(command) ⇒ Boolean
Methods included from PlaceCommandParser
Methods inherited from Base
Class Method Details
.build_from_string_command(command) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/robot/commands/place.rb', line 20 def self.build_from_string_command(command) x, y, f = parse(command) x = x.to_i y = y.to_i f = f.to_sym call(x: x, y: y, f: f) end |
.call(x:, y:, f:) ⇒ Object
16 17 18 |
# File 'lib/robot/commands/place.rb', line 16 def self.call(x:, y:, f:) Robot::Position.new(point: Point.new(x: x, y: y), direction: f) end |
.matches?(command) ⇒ Boolean
12 13 14 |
# File 'lib/robot/commands/place.rb', line 12 def self.matches?(command) command =~ REGEX end |