Module: Text2048::MonkeyPatch::Array::Board

Included in:
Array
Defined in:
lib/text2048/monkey_patch/array/board.rb

Overview

2048 related methods

Instance Method Summary collapse

Instance Method Details

#hashinizeObject



9
10
11
12
13
14
15
16
# File 'lib/text2048/monkey_patch/array/board.rb', line 9

def hashinize
  col_row = [0, 1, 2, 3].product([0, 1, 2, 3])
  col_row.each_with_object({}) do |(col, row), memo|
    tile = self[col][row]
    memo[[col, row]] =
      tile.respond_to?(:status) ? tile : Text2048::Tile.new(tile)
  end
end