another_toy_robot 0.1.4 → 0.1.5
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 +4 -4
- data/lib/toy_robot/arena.rb +2 -4
- data/lib/toy_robot/null_position.rb +5 -1
- data/lib/toy_robot/position.rb +12 -6
- data/lib/toy_robot/robot.rb +2 -2
- data/lib/toy_robot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 703254bc3ea33248766b65e7bf4374df5501671d
|
4
|
+
data.tar.gz: 3ec88b6ea2e8640b5eedf89f1642dc4a239c8921
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22e6167b33a800b5372211043377351159bacc5a4befe0259c697fab103f91ad407afd89dc7e47a8b4d43b0719b17e86013aea31c839e4ff9db77724f50d2da2
|
7
|
+
data.tar.gz: c58469894d5c0834a18660baf0c6bca5bb47b3c77dccd6c50a896713c5116bff44d53154b212b2e8dfe955414184f54165846dbe4a97072fa1f51695f423f248
|
data/lib/toy_robot/arena.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
class Arena
|
2
|
-
attr_accessor :width, :height
|
3
|
-
|
4
2
|
def initialize(width:, height:)
|
5
3
|
@width = width
|
6
4
|
@height = height
|
@@ -13,10 +11,10 @@ class Arena
|
|
13
11
|
private
|
14
12
|
|
15
13
|
def max_x
|
16
|
-
width - 1
|
14
|
+
@width - 1
|
17
15
|
end
|
18
16
|
|
19
17
|
def max_y
|
20
|
-
height - 1
|
18
|
+
@height - 1
|
21
19
|
end
|
22
20
|
end
|
data/lib/toy_robot/position.rb
CHANGED
@@ -8,15 +8,21 @@ class Position
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def advance
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
Position.new(x_coord: @x_coord + @direction.x_displacement,
|
12
|
+
y_coord: @y_coord + @direction.y_displacement,
|
13
|
+
direction: @direction)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def left
|
17
17
|
Position.new(x_coord: @x_coord,
|
18
|
-
|
19
|
-
|
18
|
+
y_coord: @y_coord,
|
19
|
+
direction: @direction.left)
|
20
|
+
end
|
21
|
+
|
22
|
+
def right
|
23
|
+
Position.new(x_coord: @x_coord,
|
24
|
+
y_coord: @y_coord,
|
25
|
+
direction: @direction.right)
|
20
26
|
end
|
21
27
|
|
22
28
|
def to_s
|
data/lib/toy_robot/robot.rb
CHANGED
data/lib/toy_robot/version.rb
CHANGED