ferencd@0: #--- ferencd@0: # Excerpted from "Mazes for Programmers", ferencd@0: # published by The Pragmatic Bookshelf. ferencd@0: # Copyrights apply to this code. It may not be used to create training material, ferencd@0: # courses, books, articles, and the like. Contact us if you are in doubt. ferencd@0: # We make no guarantees that this code is fit for any purpose. ferencd@0: # Visit http://www.pragmaticprogrammer.com/titles/jbmaze for more book information. ferencd@0: #--- ferencd@0: require 'grid' ferencd@0: ferencd@0: class DistanceGrid < Grid ferencd@0: attr_accessor :distances ferencd@0: ferencd@0: def contents_of(cell) ferencd@0: if distances && distances[cell] ferencd@0: distances[cell].to_s ferencd@0: else ferencd@0: super ferencd@0: end ferencd@0: end ferencd@0: end