toy_robot_cli 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/toy_robot_cli/robot.rb +19 -0
- data/lib/toy_robot_cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c145bb96e64a3e559084b341f50a38efec5f235b12bf946babe0c2bc2376ab64
|
4
|
+
data.tar.gz: 39c2783f9367048e8346dd8b45db6d4ae9c340b1062e8694b949493f566b4a8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d92addaad468bfdd6375b3b3771c9657eec02ab4297e7c969340273f9ae3c79f44dcef3076bc0f3d4089371e1745bbe5335a134ca51c28daacb79fb2f450e9da
|
7
|
+
data.tar.gz: c935935c5e16189f8105ba8477ee9d41a2a823dd6a1be4704cc85a56601ba10071ebf7e9285646c846eb24dee8b6b1dd78b2fb85c166fe598b7a4bc2a5bae24f
|
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
|
@@ -54,6 +56,10 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
54
56
|
|
55
57
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
56
58
|
|
59
|
+
### Docs
|
60
|
+
|
61
|
+
`rdoc lib/toy_robot_cli/robot.rb`
|
62
|
+
|
57
63
|
## Contributing
|
58
64
|
|
59
65
|
Bug reports and pull requests are welcome on GitHub at https://github.com/phsacramento/toy_robot_cli.
|
data/lib/toy_robot_cli/robot.rb
CHANGED
@@ -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
|
+
# => [0, 0]
|
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?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toy_robot_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paulo H Sacramento
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aruba
|