another_toy_robot 0.1.6 → 0.1.7

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
  SHA1:
3
- metadata.gz: 0df55e5f413842d0e311ceda77fcb2a33362df2e
4
- data.tar.gz: 844a8cd8dab9ba6f4a2df3257896f67f64d91795
3
+ metadata.gz: 1399909208387cd5e03c5a6f89aa61623879d178
4
+ data.tar.gz: 974d0f67de3463964cbd82cffb1e0180b0db7a0a
5
5
  SHA512:
6
- metadata.gz: ee2b5384f9394d1ffed64856b825d3eab517536a6621b7ad22df0b3c56991c2b524da031c15c3a0696800524f19db9117dc9870fbedafbe29d0a72a7a24e30fa
7
- data.tar.gz: e4f116f2b6284cdcc67efc88c8eb8d5955848ed600bb4f3dfe99f19b64ada61519f6371722fe26a12a340f8828c3c2bf44fcf80e9e9d77dd62da5bdd78fb9b1c
6
+ metadata.gz: c79ac33ccca492a640630470d447ea98458c20ca1e939b185fa6d4502a849cd53f50f420dcaa224dabef1d93f8b991ba426b2789a6b67d9fbd4252e95206d922
7
+ data.tar.gz: 7c789bed5f724ff5609751fb9dbb72c439a354addbb92c7be9f8b2afc182b82213e611523fc944567627682211c44549746f59207b6060b38757622fe61b6cdf
@@ -22,10 +22,10 @@ class PlaceCommand
22
22
 
23
23
  def direction
24
24
  case @params[2]
25
- when "n", "north" then North.new
26
- when "e", "east" then East.new
27
- when "s", "south" then South.new
28
- when "w", "west" then West.new
25
+ when "n", "north" then North
26
+ when "e", "east" then East
27
+ when "s", "south" then South
28
+ when "w", "west" then West
29
29
  end
30
30
  end
31
31
  end
@@ -1,67 +1,51 @@
1
- class Direction
2
- attr_reader :x_displacement, :y_displacement
1
+ module North
2
+ X_DISPLACEMENT = 0
3
+ Y_DISPLACEMENT = 1
3
4
 
4
- def to_s
5
- self.class.to_s.downcase
6
- end
7
- end
8
-
9
- class North < Direction
10
- def initialize
11
- @x_displacement = 0
12
- @y_displacement = 1
13
- end
14
-
15
- def left
16
- West.new
5
+ def self.left
6
+ West
17
7
  end
18
8
 
19
- def right
20
- East.new
9
+ def self.right
10
+ East
21
11
  end
22
12
  end
23
13
 
24
- class East < Direction
25
- def initialize
26
- @x_displacement = 1
27
- @y_displacement = 0
28
- end
14
+ module East
15
+ X_DISPLACEMENT = 1
16
+ Y_DISPLACEMENT = 0
29
17
 
30
- def left
31
- North.new
18
+ def self.left
19
+ North
32
20
  end
33
21
 
34
- def right
35
- South.new
22
+ def self.right
23
+ South
36
24
  end
37
25
  end
38
26
 
39
- class South < Direction
40
- def initialize
41
- @x_displacement = 0
42
- @y_displacement = -1
43
- end
27
+ module South
28
+ X_DISPLACEMENT = 0
29
+ Y_DISPLACEMENT = -1
44
30
 
45
- def left
46
- East.new
31
+ def self.left
32
+ East
47
33
  end
48
34
 
49
- def right
50
- West.new
35
+ def self.right
36
+ West
51
37
  end
52
38
  end
53
39
 
54
- class West < Direction
55
- def initialize
56
- @x_displacement = -1
57
- @y_displacement = 0
58
- end
40
+ module West
41
+ X_DISPLACEMENT = -1
42
+ Y_DISPLACEMENT = 0
59
43
 
60
- def left
61
- South.new
44
+ def self.left
45
+ South
62
46
  end
63
47
 
64
- def right
65
- North.new
48
+ def self.right
49
+ North
66
50
  end
67
51
  end
@@ -1,15 +1,15 @@
1
1
  class Position
2
2
  attr_reader :x_coord, :y_coord, :direction
3
3
 
4
- def initialize(x_coord: 0, y_coord: 0, direction: North.new)
4
+ def initialize(x_coord: 0, y_coord: 0, direction: North)
5
5
  @x_coord = x_coord
6
6
  @y_coord = y_coord
7
7
  @direction = direction
8
8
  end
9
9
 
10
10
  def advance
11
- Position.new(x_coord: @x_coord + @direction.x_displacement,
12
- y_coord: @y_coord + @direction.y_displacement,
11
+ Position.new(x_coord: @x_coord + @direction::X_DISPLACEMENT,
12
+ y_coord: @y_coord + @direction::Y_DISPLACEMENT,
13
13
  direction: @direction)
14
14
  end
15
15
 
@@ -1,3 +1,3 @@
1
1
  module ToyRobot
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/toy_robot.gemspec CHANGED
@@ -6,7 +6,7 @@ require 'toy_robot/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "another_toy_robot"
8
8
  spec.version = ToyRobot::VERSION
9
- spec.date = "2016-11-30"
9
+ spec.date = "2016-12-01"
10
10
  spec.authors = "Sheldon J. Johnson"
11
11
  spec.email = "sheldon.j.johnson@outlook.com"
12
12
  spec.homepage = "https://github.com/drzel/toy_robot"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: another_toy_robot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sheldon J. Johnson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-30 00:00:00.000000000 Z
11
+ date: 2016-12-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "The application is a simulation of a toy robot moving on a square tabletop.\nIt
14
14
  is an example of a well tested, object oriented design, employing the \ncommand