class Tictactoe::Players::Factory

Attributes

factories[RW]

Public Class Methods

new() click to toggle source
# File lib/tictactoe/players/factory.rb, line 4
def initialize()
  @factories = {}
end

Public Instance Methods

create(type, mark) click to toggle source
# File lib/tictactoe/players/factory.rb, line 8
def create(type, mark)
  raise "No factory has been defined for type: #{type}" unless factories.has_key?(type)
  factories[type].call(mark)
end
register(type, factory) click to toggle source
# File lib/tictactoe/players/factory.rb, line 13
def register(type, factory)
  factories[type] = factory
end