annotate 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
rev   line source
ferencd@0 1 #---
ferencd@0 2 # Excerpted from "Mazes for Programmers",
ferencd@0 3 # published by The Pragmatic Bookshelf.
ferencd@0 4 # Copyrights apply to this code. It may not be used to create training material,
ferencd@0 5 # courses, books, articles, and the like. Contact us if you are in doubt.
ferencd@0 6 # We make no guarantees that this code is fit for any purpose.
ferencd@0 7 # Visit http://www.pragmaticprogrammer.com/titles/jbmaze for more book information.
ferencd@0 8 #---
ferencd@0 9 require 'grid'
ferencd@0 10
ferencd@0 11 class DistanceGrid < Grid
ferencd@0 12 attr_accessor :distances
ferencd@0 13
ferencd@0 14 def contents_of(cell)
ferencd@0 15 if distances && distances[cell]
ferencd@0 16 distances[cell].to_s
ferencd@0 17 else
ferencd@0 18 super
ferencd@0 19 end
ferencd@0 20 end
ferencd@0 21 end