toy_robot_cli 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b9465bbbfd49f2de70e762e66b8ebb85a42e058e047dc190d459c4cfa9e0674
4
- data.tar.gz: c1d8c7b25605ba93871bae39756c0f0f9f86c263dd784f789b4156cc7a645283
3
+ metadata.gz: 5a3133755b582dabf6ef44af7158ab89e3fbf6c92a765e579ebd2e38b736b7d7
4
+ data.tar.gz: a6c15e28cd2c552f4e5a5fe37cbdb2e903311fac82676c8c6de7960dcb2f0c52
5
5
  SHA512:
6
- metadata.gz: 2f9bd0a617f9fc83256dfeae4ef9ef879f761f49b9a4c00642b322792beacaf50223cb02fdf48954bc46dbc7a8da2e729e6d107cfa23dc282a311a34e58a7cc3
7
- data.tar.gz: 06367b0746873f1af22aa0b9e0a0bc9e103683d501f9183274307201e1c170ad0b4c97e6fb9f7f07007ad7e2d65d83e7c2fa9745a01fb90010f496cd61fda3a8
6
+ metadata.gz: ca4c27c5b823f86f59d96ea39d60d88409d70165108671dd543c88e86f4570fee619420735456dde3f4d21b11490ffebb7472423443482d03ec46a7c6369efea
7
+ data.tar.gz: fbd92d9c66ef0ab748296773933f55947e0535b585c67d77d1c475ab8369a67999c04de2c9e8ca1b266d610f0cdb0cf5948d2b17a9c1e25a321765281cb20acb
data/README.md CHANGED
@@ -34,6 +34,7 @@ The available commands are:
34
34
  - right: Rotate the robot 90 degrees to the right.
35
35
  - report: Report the current position and direction of the robot.
36
36
  - current_position: Report the current position of the robot.
37
+ - current_direction: Report the current direction of the robot is facing.
37
38
 
38
39
  Here's an example usage:
39
40
 
@@ -46,6 +47,7 @@ $ toy_robot
46
47
  > move
47
48
  > report
48
49
  > current_position
50
+ > current_direction
49
51
  ```
50
52
 
51
53
  ## Development
@@ -38,6 +38,8 @@ module ToyRobotCli
38
38
  # => #<ToyRobotCli::Robot:0x000000... @direction=nil, @position=nil>
39
39
  # >> robot.place(0, 0, "SOUTH")
40
40
  # => 2
41
+ # >> robot.current_position
42
+ # => [2, 2]
41
43
  #
42
44
  # Returns:
43
45
  # (Array) - An array containing the X and Y coordinates of the robot's current position.
@@ -47,6 +49,23 @@ module ToyRobotCli
47
49
  @position.to_a.flatten
48
50
  end
49
51
 
52
+ # Get the current direction of the robot.
53
+ # Example:
54
+ # >> robot = ToyRobotCli::Robot.new
55
+ # => #<ToyRobotCli::Robot:0x000000... @direction=nil, @position=nil>
56
+ # >> robot.place(0, 0, "SOUTH")
57
+ # => 2
58
+ # >> robot.current_direction
59
+ # => "SOUTH"
60
+ #
61
+ # Returns:
62
+ # (String) - An array containing the X and Y coordinates of the robot's current position.
63
+ def current_direction
64
+ return nil unless placed?
65
+
66
+ VALID_DIRECTIONS[@direction]
67
+ end
68
+
50
69
  # Move the robot one unit forward in the current direction.
51
70
  def move
52
71
  return unless placed?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ToyRobotCli
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toy_robot_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo H Sacramento