Class: Piece
- Inherits:
-
Object
- Object
- Piece
- Includes:
- Constants
- Defined in:
- lib/software_challenge_client/piece.rb
Overview
Ein Spielstein mit Ausrichtung, Koordinaten und Farbe
Constant Summary
Constants included from Constants
Constants::BOARD_SIZE, Constants::GAME_IDENTIFIER, Constants::ROUND_LIMIT
Instance Attribute Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(team, coords = Coordinates.origin) ⇒ Piece
constructor
Erstellt einen neuen Spielstein.
- #inspect ⇒ Object
-
#to_s ⇒ String
Gibt die String-Repräsentation zurück.
-
#to_ss ⇒ String
To short string.
Constructor Details
#initialize(team, coords = Coordinates.origin) ⇒ Piece
Erstellt einen neuen Spielstein.
18 19 20 21 |
# File 'lib/software_challenge_client/piece.rb', line 18 def initialize(team, coords = Coordinates.origin) @team = team @coords = coords end |
Instance Attribute Details
#coords ⇒ Coordinates
15 16 17 |
# File 'lib/software_challenge_client/piece.rb', line 15 def coords @coords end |
#Koordinaten ⇒ Coordinates
15 |
# File 'lib/software_challenge_client/piece.rb', line 15 attr_accessor :coords |
Instance Method Details
#==(other) ⇒ Object
23 24 25 26 27 |
# File 'lib/software_challenge_client/piece.rb', line 23 def ==(other) !other.nil? && team == other.team && coords == other.coords end |
#inspect ⇒ Object
40 41 42 |
# File 'lib/software_challenge_client/piece.rb', line 40 def inspect to_s end |
#to_s ⇒ String
Returns Gibt die String-Repräsentation zurück.
30 31 32 |
# File 'lib/software_challenge_client/piece.rb', line 30 def to_s "#{team.key} at #{coords}" end |
#to_ss ⇒ String
To short string
36 37 38 |
# File 'lib/software_challenge_client/piece.rb', line 36 def to_ss "#{team.key.to_s[0]}" end |