Class: JustChess::PieceFactory
- Inherits:
-
Object
- Object
- JustChess::PieceFactory
- Defined in:
- lib/just_chess/piece_factory.rb
Overview
Piece Factory
Generates pieces from a hash of arguments
Constant Summary collapse
- CLASSES =
A mapping of type descriptions to classes
{ 'pawn' => Pawn, 'rook' => Rook, 'knight' => Knight, 'bishop' => Bishop, 'queen' => Queen, 'king' => King }
Instance Method Summary collapse
-
#build ⇒ Piece
Returns a piece based on the initial arguments.
-
#initialize(args) ⇒ PieceFactory
constructor
New objects can be instantiated by passing in a hash or the piece.
Constructor Details
#initialize(args) ⇒ PieceFactory
New objects can be instantiated by passing in a hash or the piece.
Example:
# Instantiates a new PieceFactory
JustChess::PieceFactory.new({
type: 'pawn',
id: 1,
player_number: 2
})
37 38 39 |
# File 'lib/just_chess/piece_factory.rb', line 37 def initialize(args) @args = args end |