Class: Piece

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(color, type) ⇒ Piece



11
12
13
14
# File 'lib/software_challenge_client/piece.rb', line 11

def initialize(color, type)
  @type = type
  @color = color
end

Instance Attribute Details

#colorPlayerColor (readonly)



9
10
11
# File 'lib/software_challenge_client/piece.rb', line 9

def color
  @color
end

#typePieceType (readonly)



5
6
7
# File 'lib/software_challenge_client/piece.rb', line 5

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
# File 'lib/software_challenge_client/piece.rb', line 16

def ==(other)
  type == other.type && color == other.color
end

#inspectObject



28
29
30
# File 'lib/software_challenge_client/piece.rb', line 28

def inspect
  to_s
end

#ownerObject



20
21
22
# File 'lib/software_challenge_client/piece.rb', line 20

def owner
  color
end

#to_sObject



24
25
26
# File 'lib/software_challenge_client/piece.rb', line 24

def to_s
  color.value + type.value
end