Class: GameObserver
- Inherits:
-
Object
- Object
- GameObserver
- Defined in:
- lib/game_observer.rb
Instance Method Summary collapse
- #game_over? ⇒ Boolean
- #has_winner? ⇒ Boolean
-
#initialize(board) ⇒ GameObserver
constructor
A new instance of GameObserver.
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
7 8 9 |
# File 'lib/game_observer.rb', line 7 def game_over? @game_board.full? || has_winner? end |
#has_winner? ⇒ Boolean
11 12 13 |
# File 'lib/game_observer.rb', line 11 def has_winner? horizontal_win? || vertical_win? || diagonal_win? end |