Class: TTT::GameHistory
- Inherits:
-
Object
- Object
- TTT::GameHistory
- Defined in:
- lib/ttt/game_history.rb
Instance Attribute Summary collapse
-
#history ⇒ Object
Returns the value of attribute history.
-
#move_traverser ⇒ Object
Returns the value of attribute move_traverser.
Instance Method Summary collapse
- #adjust_move_index(index_diff) ⇒ Object
- #get_history_board(board, move_number_limit = move_traverser.move_index) ⇒ Object
- #inc_move_index ⇒ Object
-
#initialize ⇒ GameHistory
constructor
A new instance of GameHistory.
- #initialize_history ⇒ Object
- #record_move(cell, side) ⇒ Object
- #show ⇒ Object
Constructor Details
#initialize ⇒ GameHistory
Returns a new instance of GameHistory.
7 8 9 10 |
# File 'lib/ttt/game_history.rb', line 7 def initialize self.history = [] self.move_traverser = MoveTraverser.new(self) end |
Instance Attribute Details
#history ⇒ Object
Returns the value of attribute history.
6 7 8 |
# File 'lib/ttt/game_history.rb', line 6 def history @history end |
#move_traverser ⇒ Object
Returns the value of attribute move_traverser.
6 7 8 |
# File 'lib/ttt/game_history.rb', line 6 def move_traverser @move_traverser end |
Instance Method Details
#adjust_move_index(index_diff) ⇒ Object
25 26 27 |
# File 'lib/ttt/game_history.rb', line 25 def adjust_move_index(index_diff) move_traverser.adjust_move_index(index_diff) end |
#get_history_board(board, move_number_limit = move_traverser.move_index) ⇒ Object
29 30 31 |
# File 'lib/ttt/game_history.rb', line 29 def get_history_board(board, move_number_limit = move_traverser.move_index) move_traverser.history_board_builder(board, move_number_limit) end |
#inc_move_index ⇒ Object
17 18 19 |
# File 'lib/ttt/game_history.rb', line 17 def inc_move_index self.move_traverser.move_index = history.length end |
#initialize_history ⇒ Object
33 34 35 |
# File 'lib/ttt/game_history.rb', line 33 def initialize_history move_traverser.initialize_history end |
#record_move(cell, side) ⇒ Object
12 13 14 15 |
# File 'lib/ttt/game_history.rb', line 12 def record_move(cell, side) self.history << MoveHistory.new(:move => cell, :side => side) inc_move_index end |
#show ⇒ Object
21 22 23 |
# File 'lib/ttt/game_history.rb', line 21 def show self.history end |