class MazeCrosser::CacheProvider

Class responsible for maintaining a cache of already solved mazes.

cache_provider = CacheProvider.new

Add solution to cache cache_provider.add(grid, solution)

Get a solution cache_provider.get_solution(grid)

Empty cache cache_provider.empty_cache!

Public Class Methods

new(solutions = {}) click to toggle source
# File lib/maze_crosser/cache_provider.rb, line 15
def initialize(solutions = {})
  @solutions = solutions
end

Public Instance Methods

add(grid, solution) click to toggle source
# File lib/maze_crosser/cache_provider.rb, line 19
def add(grid, solution)
  @solutions[grid] = solution
end
empty_cache!() click to toggle source
# File lib/maze_crosser/cache_provider.rb, line 27
def empty_cache!
  @solutions = {}
end
get_solution(grid) click to toggle source
# File lib/maze_crosser/cache_provider.rb, line 23
def get_solution(grid)
  @solutions[grid]
end