class TicTacToe::PlayerList

Constants

AVAILABLE_PLAYERS

Public Class Methods

new(number) click to toggle source
# File lib/tic_tac_toe/player.rb, line 15
def initialize(number)
  @players     = AVAILABLE_PLAYERS.first(number)
  @current_idx = 0
end

Public Instance Methods

colors() click to toggle source
# File lib/tic_tac_toe/player.rb, line 32
def colors
  @players.inject({}) do |colors, player|
    colors.update(player.symbol => player.color)
  end
end
current() click to toggle source
# File lib/tic_tac_toe/player.rb, line 24
def current
  @players[@current_idx]
end
each(&block) click to toggle source
# File lib/tic_tac_toe/player.rb, line 20
def each(&block)
  @players.each(&block)
end
next!() click to toggle source
# File lib/tic_tac_toe/player.rb, line 28
def next!
  @current_idx = (@current_idx + 1) % @players.count
end