diff distance_grid.rb @ 0:1eef88068f9f tip

initial commit of maze game source
author ferencd
date Sun, 15 Sep 2019 11:46:47 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distance_grid.rb	Sun Sep 15 11:46:47 2019 +0200
@@ -0,0 +1,21 @@
+#---
+# Excerpted from "Mazes for Programmers",
+# published by The Pragmatic Bookshelf.
+# Copyrights apply to this code. It may not be used to create training material, 
+# courses, books, articles, and the like. Contact us if you are in doubt.
+# We make no guarantees that this code is fit for any purpose. 
+# Visit http://www.pragmaticprogrammer.com/titles/jbmaze for more book information.
+#---
+require 'grid'
+
+class DistanceGrid < Grid
+  attr_accessor :distances
+
+  def contents_of(cell)
+    if distances && distances[cell]
+      distances[cell].to_s
+    else
+      super
+    end
+  end
+end