diff options
Diffstat (limited to 'lib/rover.rb')
| -rw-r--r-- | lib/rover.rb | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/rover.rb b/lib/rover.rb index 90d7757..8b992e9 100644 --- a/lib/rover.rb +++ b/lib/rover.rb @@ -1,11 +1,11 @@ class Rover attr_reader :location def initialize(heading, coordinates) - @heading = Direction.find(heading) + @heading = heading @location = coordinates end def heading - @heading.direction + @heading.to_sym end def turn_right @heading = @heading.turn_right @@ -19,7 +19,7 @@ class Rover end class North - def direction + def to_sym :north end def turn_right @@ -33,7 +33,7 @@ class North end end class East - def direction + def to_sym :east end def turn_right @@ -47,7 +47,7 @@ class East end end class West - def direction + def to_sym :west end def turn_right @@ -61,7 +61,7 @@ class West end end class South - def direction + def to_sym :south end def turn_right @@ -74,10 +74,3 @@ class South current_location[:y] = current_location[:y]-1 end end - -class Direction - @@directions = {:north => North.new, :east => East.new, :west => West.new, :south => South.new} - def self.find(heading) - @@directions[heading] - end -end |
