Class: ChessData::Moves::SimplePawnMove

Inherits:
Object
  • Object
show all
Defined in:
lib/chess_data/moves.rb

Overview

Methods to support a simple pawn move, moving directly forward.

Direct Known Subclasses

PromotionPawnMove

Instance Method Summary collapse

Constructor Details

#initialize(move) ⇒ SimplePawnMove

Returns a new instance of SimplePawnMove.



262
263
264
265
266
# File 'lib/chess_data/moves.rb', line 262

def initialize move
  @move_string = move
  move =~ MatchSimplePawnMove
  @destination = $1
end

Instance Method Details

#make_move(board) ⇒ Object

Returns a new instance of the board after move is made.



273
274
275
276
277
278
279
# File 'lib/chess_data/moves.rb', line 273

def make_move board
  if board.to_move == "w"
    white_move board
  else
    black_move board
  end
end

#to_sObject



268
269
270
# File 'lib/chess_data/moves.rb', line 268

def to_s
  @move_string
end