Class: TicTacToe::Squares
- Inherits:
-
Array
- Object
- Array
- TicTacToe::Squares
- Defined in:
- lib/tic_tac_toe_mchliakh/board/squares.rb
Instance Method Summary collapse
- #all_equal? ⇒ Boolean
- #all_taken? ⇒ Boolean
- #empty ⇒ Object
- #taken_by(player) ⇒ Object
- #taken_by_opponent(player) ⇒ Object
Instance Method Details
#all_equal? ⇒ Boolean
19 20 21 |
# File 'lib/tic_tac_toe_mchliakh/board/squares.rb', line 19 def all_equal? all? {|s| s == first } end |
#all_taken? ⇒ Boolean
15 16 17 |
# File 'lib/tic_tac_toe_mchliakh/board/squares.rb', line 15 def all_taken? none?(&:empty?) end |
#empty ⇒ Object
3 4 5 |
# File 'lib/tic_tac_toe_mchliakh/board/squares.rb', line 3 def empty select(&:empty?) end |
#taken_by(player) ⇒ Object
7 8 9 |
# File 'lib/tic_tac_toe_mchliakh/board/squares.rb', line 7 def taken_by(player) select {|s| s.taken_by?(player) } end |
#taken_by_opponent(player) ⇒ Object
11 12 13 |
# File 'lib/tic_tac_toe_mchliakh/board/squares.rb', line 11 def taken_by_opponent(player) select {|s| s.taken_by_opponent?(player) } end |