Class: Piece
- Inherits:
-
Object
- Object
- Piece
- Defined in:
- lib/software_challenge_client/piece.rb
Overview
Ein Spielstein mit Ausrichtung, Koordinaten und Farbe
Instance Attribute Summary collapse
- #color ⇒ Color readonly
-
#coords ⇒ Object
readonly
Returns the value of attribute coords.
- #Drehung ⇒ Rotation readonly
- #Farbe ⇒ Color readonly
- #Form ⇒ PieceShape readonly
- #is_flipped ⇒ Boolean readonly
- #kind ⇒ PieceShape readonly
- #Koordinaten ⇒ Coordinates readonly
- #Ob der Stein an der Y-Achse gespiegelt ist(derSteinanderY-Achsegespiegeltist) ⇒ Boolean readonly
- #position ⇒ Coordinates readonly
- #rotation ⇒ Rotation readonly
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(color, kind, rotation = Rotation::NONE, is_flipped = false, position = Coordinates.origin) ⇒ Piece
constructor
Erstellt einen neuen leeren Spielstein.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(color, kind, rotation = Rotation::NONE, is_flipped = false, position = Coordinates.origin) ⇒ Piece
Erstellt einen neuen leeren Spielstein.
28 29 30 31 32 33 34 35 36 |
# File 'lib/software_challenge_client/piece.rb', line 28 def initialize(color, kind, rotation = Rotation::NONE, is_flipped = false, position = Coordinates.origin) @color = color @kind = kind @rotation = rotation @is_flipped = is_flipped @position = position @coords = coords_priv end |
Instance Attribute Details
#color ⇒ Color (readonly)
7 8 9 |
# File 'lib/software_challenge_client/piece.rb', line 7 def color @color end |
#coords ⇒ Object (readonly)
Returns the value of attribute coords.
25 26 27 |
# File 'lib/software_challenge_client/piece.rb', line 25 def coords @coords end |
#Drehung ⇒ Rotation (readonly)
15 |
# File 'lib/software_challenge_client/piece.rb', line 15 attr_reader :rotation |
#Farbe ⇒ Color (readonly)
7 |
# File 'lib/software_challenge_client/piece.rb', line 7 attr_reader :color |
#Form ⇒ PieceShape (readonly)
11 |
# File 'lib/software_challenge_client/piece.rb', line 11 attr_reader :kind |
#is_flipped ⇒ Boolean (readonly)
19 20 21 |
# File 'lib/software_challenge_client/piece.rb', line 19 def is_flipped @is_flipped end |
#kind ⇒ PieceShape (readonly)
11 12 13 |
# File 'lib/software_challenge_client/piece.rb', line 11 def kind @kind end |
#Koordinaten ⇒ Coordinates (readonly)
23 |
# File 'lib/software_challenge_client/piece.rb', line 23 attr_reader :position |
#Ob der Stein an der Y-Achse gespiegelt ist(derSteinanderY-Achsegespiegeltist) ⇒ Boolean (readonly)
19 |
# File 'lib/software_challenge_client/piece.rb', line 19 attr_reader :is_flipped |
#position ⇒ Coordinates (readonly)
23 24 25 |
# File 'lib/software_challenge_client/piece.rb', line 23 def position @position end |
#rotation ⇒ Rotation (readonly)
15 16 17 |
# File 'lib/software_challenge_client/piece.rb', line 15 def rotation @rotation end |
Instance Method Details
#==(other) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/software_challenge_client/piece.rb', line 38 def ==(other) color == other.color && kind == other.kind && rotation == other.rotation && is_flipped == other.is_flipped && position == other.position end |
#inspect ⇒ Object
50 51 52 |
# File 'lib/software_challenge_client/piece.rb', line 50 def inspect to_s end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/software_challenge_client/piece.rb', line 46 def to_s "#{color.key} #{kind.key} at #{position} rotation #{rotation.key}#{is_flipped ? ' (flipped)' : ''}" end |