Class: TicTacToe::Squares

Inherits:
Array
  • Object
show all
Defined in:
lib/tic_tac_toe_mchliakh/board/squares.rb

Instance Method Summary collapse

Instance Method Details

#all_equal?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


15
16
17
# File 'lib/tic_tac_toe_mchliakh/board/squares.rb', line 15

def all_taken?
  none?(&:empty?)
end

#emptyObject



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