another_toy_robot 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8d1128303c93b1075d61df54fa152297c37f8d3
4
- data.tar.gz: f7eb58a07a7333905b4655d9032c3fdd83d7aae8
3
+ metadata.gz: 703254bc3ea33248766b65e7bf4374df5501671d
4
+ data.tar.gz: 3ec88b6ea2e8640b5eedf89f1642dc4a239c8921
5
5
  SHA512:
6
- metadata.gz: 7360190bc39b05b0ba27907ba6174cc0c683dfd9d4fd85436297568643f9634eddacdb5759d84450bbd2a96db3fc482d6bfb3a303cfc5361731ce862e56ed5d4
7
- data.tar.gz: bf0b75a09de010a969ce596a2f839fb0802e4828f91c048554aa501c6bc13f18721149bc2f78099566b376656dfe02bd8ae381ab56dbba06e6446c66a65fd0a4
6
+ metadata.gz: 22e6167b33a800b5372211043377351159bacc5a4befe0259c697fab103f91ad407afd89dc7e47a8b4d43b0719b17e86013aea31c839e4ff9db77724f50d2da2
7
+ data.tar.gz: c58469894d5c0834a18660baf0c6bca5bb47b3c77dccd6c50a896713c5116bff44d53154b212b2e8dfe955414184f54165846dbe4a97072fa1f51695f423f248
@@ -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
@@ -12,7 +12,11 @@ class NullPosition
12
12
  self
13
13
  end
14
14
 
15
- def turn(*)
15
+ def left
16
+ self
17
+ end
18
+
19
+ def right
16
20
  self
17
21
  end
18
22
  end
@@ -8,15 +8,21 @@ class Position
8
8
  end
9
9
 
10
10
  def advance
11
- x = @x_coord + @direction.x_displacement
12
- y = @y_coord + @direction.y_displacement
13
- Position.new x_coord: x, y_coord: y, direction: @direction
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 turn(hand_side)
16
+ def left
17
17
  Position.new(x_coord: @x_coord,
18
- y_coord: @y_coord,
19
- direction: @direction.send(hand_side))
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
@@ -15,11 +15,11 @@ class Robot
15
15
  end
16
16
 
17
17
  def left
18
- @position = @position.turn :left
18
+ @position = @position.left
19
19
  end
20
20
 
21
21
  def right
22
- @position = @position.turn :right
22
+ @position = @position.right
23
23
  end
24
24
 
25
25
  def report
@@ -1,3 +1,3 @@
1
1
  module ToyRobot
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: another_toy_robot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sheldon J. Johnson