Class: ChessEngine::Pawn

Inherits:
Piece
  • Object
show all
Defined in:
lib/chess_engine/piece.rb

Instance Attribute Summary collapse

Attributes inherited from Piece

#color, #moves_count, #symbol

Instance Method Summary collapse

Methods inherited from Piece

#beats_diagonally?, #beats_straight?, #inspect

Constructor Details

#initialize(color) ⇒ Pawn

Returns a new instance of Pawn.



68
69
70
71
72
# File 'lib/chess_engine/piece.rb', line 68

def initialize(color)
  super
  @symbol = (@color == :black) ? "\u265F" : "\u2659"
  @direction = (@color == :white) ? 1 : -1
end

Instance Attribute Details

#directionObject (readonly)

Returns the value of attribute direction.



66
67
68
# File 'lib/chess_engine/piece.rb', line 66

def direction
  @direction
end