Class: JbcdenTtt::Player
- Inherits:
-
Object
- Object
- JbcdenTtt::Player
- Defined in:
- lib/jbcden_ttt/player.rb
Defined Under Namespace
Classes: InvalidCharacterError
Instance Attribute Summary collapse
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
Instance Method Summary collapse
- #human? ⇒ Boolean
-
#initialize(symbol) ⇒ Player
constructor
A new instance of Player.
- #make_move(board, coordinate) ⇒ Object
Constructor Details
#initialize(symbol) ⇒ Player
Returns a new instance of Player.
9 10 11 12 13 14 15 |
# File 'lib/jbcden_ttt/player.rb', line 9 def initialize(symbol) if symbol == "x" || symbol == "o" @symbol = symbol else raise InvalidCharacterError end end |
Instance Attribute Details
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
8 9 10 |
# File 'lib/jbcden_ttt/player.rb', line 8 def symbol @symbol end |
Instance Method Details
#human? ⇒ Boolean
22 23 24 |
# File 'lib/jbcden_ttt/player.rb', line 22 def human? true end |
#make_move(board, coordinate) ⇒ Object
17 18 19 20 |
# File 'lib/jbcden_ttt/player.rb', line 17 def make_move(board, coordinate) tile = BoardMapper.map_string(board, coordinate) tile.mark(symbol) end |