Class: ChessData::Moves::PromotionPawnMove
- Inherits:
-
SimplePawnMove
- Object
- SimplePawnMove
- ChessData::Moves::PromotionPawnMove
- Defined in:
- lib/chess_data/moves.rb
Overview
Methods to support a pawn move leading to promotion.
Instance Method Summary collapse
-
#initialize(string) ⇒ PromotionPawnMove
constructor
A new instance of PromotionPawnMove.
-
#make_move(board) ⇒ Object
Returns a new instance of the board after move is made.
Methods inherited from SimplePawnMove
Constructor Details
#initialize(string) ⇒ PromotionPawnMove
Returns a new instance of PromotionPawnMove.
368 369 370 371 372 373 374 |
# File 'lib/chess_data/moves.rb', line 368 def initialize string @move_string = string string =~ MatchPromotionPawnMove string.split("=") @destination = $1 @piece = $2 end |
Instance Method Details
#make_move(board) ⇒ Object
Returns a new instance of the board after move is made.
377 378 379 380 381 382 |
# File 'lib/chess_data/moves.rb', line 377 def make_move board @piece.downcase! if board.to_move == "b" revised_board = super board revised_board[@destination] = @piece return revised_board end |