class TicTacToeRZ::GamePlay::GameBoard
Attributes
board[R]
Public Class Methods
create_board()
click to toggle source
# File lib/tic_tac_toe_rz/tictactoeruby.core/gameplay/game_board.rb, line 16 def self.create_board board = ["1", "2", "3", "4", "5", "6", "7", "8", "9"] end
new(board)
click to toggle source
# File lib/tic_tac_toe_rz/tictactoeruby.core/gameplay/game_board.rb, line 10 def initialize(board) raise Exceptions::NilReferenceError, "board" if board.nil? raise Exceptions::InvalidValueError, "board" if board.size == 0 @board = board end
Public Instance Methods
revert_board(index)
click to toggle source
# File lib/tic_tac_toe_rz/tictactoeruby.core/gameplay/game_board.rb, line 26 def revert_board(index) raise Exceptions::InvalidValueError, "index" if index >= board.length || index < 0 tile = index + 1 @board[index] = tile.to_s end
tile(index)
click to toggle source
# File lib/tic_tac_toe_rz/tictactoeruby.core/gameplay/game_board.rb, line 32 def tile(index) raise Exceptions::InvalidValueError, "index" if index >= board.length || index < 0 board[index] end
update_board(index, player_symbol)
click to toggle source
# File lib/tic_tac_toe_rz/tictactoeruby.core/gameplay/game_board.rb, line 20 def update_board(index, player_symbol) raise Exceptions::InvalidValueError, "player_symbol" if !Validators::PlayerSymbolValidator.valid?(player_symbol) raise Exceptions::InvalidValueError, "index" if index >= board.length || index < 0 @board[index] = player_symbol end