Class: TicTacToe::Player::Human
- Inherits:
-
Object
- Object
- TicTacToe::Player::Human
- Includes:
- MoveJson
- Defined in:
- lib/tic_tac_toe/players/human_player.rb
Instance Attribute Summary collapse
-
#letter ⇒ Object
readonly
Returns the value of attribute letter.
-
#move ⇒ Object
writeonly
Sets the attribute move.
Instance Method Summary collapse
- #get_move(_board) ⇒ Object
- #has_next_move? ⇒ Boolean
-
#initialize(params) ⇒ Human
constructor
A new instance of Human.
- #type ⇒ Object
Methods included from MoveJson
Constructor Details
#initialize(params) ⇒ Human
Returns a new instance of Human.
11 12 13 14 |
# File 'lib/tic_tac_toe/players/human_player.rb', line 11 def initialize(params) @letter, @move = (params['letter'] || params[:letter]), (params['move'] || params[:move]) end |
Instance Attribute Details
#letter ⇒ Object (readonly)
Returns the value of attribute letter.
8 9 10 |
# File 'lib/tic_tac_toe/players/human_player.rb', line 8 def letter @letter end |
#move=(value) ⇒ Object (writeonly)
Sets the attribute move
9 10 11 |
# File 'lib/tic_tac_toe/players/human_player.rb', line 9 def move=(value) @move = value end |
Instance Method Details
#get_move(_board) ⇒ Object
16 17 18 19 20 |
# File 'lib/tic_tac_toe/players/human_player.rb', line 16 def get_move(_board) move = @move @move = nil move end |
#has_next_move? ⇒ Boolean
22 23 24 |
# File 'lib/tic_tac_toe/players/human_player.rb', line 22 def has_next_move? !!@move end |