Class: TicTacToe::Rules

Inherits:
Object
  • Object
show all
Defined in:
lib/tic_tac_toe/rules.rb

Instance Method Summary collapse

Constructor Details

#initialize(goal) ⇒ Rules

Returns a new instance of Rules.



3
4
5
# File 'lib/tic_tac_toe/rules.rb', line 3

def initialize(goal)
  @goal = goal
end

Instance Method Details

#game_over?(board, players) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/tic_tac_toe/rules.rb', line 7

def game_over?(board, players)
  players.any? { |player| player_won?(player, board) } or board_full?(board)
end