Class: Chess::Pieces::Piece
- Inherits:
-
Object
- Object
- Chess::Pieces::Piece
- Defined in:
- lib/chess/pieces/piece.rb
Overview
Piece
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#pos ⇒ Object
Returns the value of attribute pos.
-
#valid_moves ⇒ Object
Returns the value of attribute valid_moves.
Instance Method Summary collapse
-
#black? ⇒ Boolean
checks if piece color is black.
-
#initialize(color) ⇒ Piece
constructor
A new instance of Piece.
-
#white? ⇒ Boolean
checks if piece color is white.
Constructor Details
#initialize(color) ⇒ Piece
Returns a new instance of Piece.
12 13 14 15 16 |
# File 'lib/chess/pieces/piece.rb', line 12 def initialize(color) @color = color @pos = [] @valid_moves = [] end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
9 10 11 |
# File 'lib/chess/pieces/piece.rb', line 9 def color @color end |
#pos ⇒ Object
Returns the value of attribute pos.
10 11 12 |
# File 'lib/chess/pieces/piece.rb', line 10 def pos @pos end |
#valid_moves ⇒ Object
Returns the value of attribute valid_moves.
10 11 12 |
# File 'lib/chess/pieces/piece.rb', line 10 def valid_moves @valid_moves end |
Instance Method Details
#black? ⇒ Boolean
checks if piece color is black
19 20 21 |
# File 'lib/chess/pieces/piece.rb', line 19 def black? @color == 'black' end |
#white? ⇒ Boolean
checks if piece color is white
24 25 26 |
# File 'lib/chess/pieces/piece.rb', line 24 def white? @color == 'white' end |