Commit 85e494c

mo k <mo@mokhan.ca>
2012-11-04 21:11:24
move Location to a separate file.
1 parent de803e2
Changed files (2)
lib/location.rb
@@ -0,0 +1,16 @@
+class Location
+  attr_reader :location, :heading
+  def initialize(x, y, heading)
+    @location = {:x => x, :y => y}
+    @heading = heading
+  end
+  def rotate(degrees)
+    @heading = @heading.rotate(degrees)
+  end
+  def is_facing(direction)
+    @heading.represents? direction
+  end
+  def to_s
+    "#{@location[:x]} #{@location[:y]} #{@heading}"
+  end
+end
lib/rover.rb
@@ -1,3 +1,4 @@
+require 'location'
 class Rover
   def initialize(heading, x, y, plateau)
     @plateau = plateau
@@ -24,20 +25,3 @@ class Rover
     @location.to_s
   end
 end
-
-class Location
-  attr_reader :location, :heading
-  def initialize(x, y, heading)
-    @location = {:x => x, :y => y}
-    @heading = heading
-  end
-  def rotate(degrees)
-    @heading = @heading.rotate(degrees)
-  end
-  def is_facing(direction)
-    @heading.represents? direction
-  end
-  def to_s
-    "#{@location[:x]} #{@location[:y]} #{@heading}"
-  end
-end