Class: GameObserver

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

Instance Method Summary collapse

Constructor Details

#initialize(board) ⇒ GameObserver

Returns a new instance of GameObserver.



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

def initialize(board)
  @game_board = board
end

Instance Method Details

#game_over?Boolean

Returns:

  • (Boolean)


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

def game_over?
  @game_board.full? || has_winner?
end

#has_winner?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/game_observer.rb', line 11

def has_winner?
  horizontal_win? || vertical_win? || diagonal_win?
end