Class: ChessEngine::Piece
- Inherits:
-
Object
- Object
- ChessEngine::Piece
- Defined in:
- lib/chess_engine/piece.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#moves_count ⇒ Object
Returns the value of attribute moves_count.
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
Instance Method Summary collapse
- #beats_diagonally? ⇒ Boolean
- #beats_straight? ⇒ Boolean
-
#initialize(color) ⇒ Piece
constructor
A new instance of Piece.
- #inspect ⇒ Object
Constructor Details
#initialize(color) ⇒ Piece
Returns a new instance of Piece.
6 7 8 9 |
# File 'lib/chess_engine/piece.rb', line 6 def initialize(color) @color = color @moves_count = 0 end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
3 4 5 |
# File 'lib/chess_engine/piece.rb', line 3 def color @color end |
#moves_count ⇒ Object
Returns the value of attribute moves_count.
4 5 6 |
# File 'lib/chess_engine/piece.rb', line 4 def moves_count @moves_count end |
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
3 4 5 |
# File 'lib/chess_engine/piece.rb', line 3 def symbol @symbol end |
Instance Method Details
#beats_diagonally? ⇒ Boolean
15 16 17 |
# File 'lib/chess_engine/piece.rb', line 15 def beats_diagonally? elephant? || queen? end |
#beats_straight? ⇒ Boolean
19 20 21 |
# File 'lib/chess_engine/piece.rb', line 19 def beats_straight? rook? || queen? end |
#inspect ⇒ Object
11 12 13 |
# File 'lib/chess_engine/piece.rb', line 11 def inspect "#{self.class}:#{@color}" end |