Class: WebGamePresenter::Base
- Inherits:
-
Object
- Object
- WebGamePresenter::Base
- Defined in:
- lib/ttt/interfaces/rails/app/presenters/web_game_presenter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#board ⇒ Object
Returns the value of attribute board.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
- #generate_form(index) ⇒ Object
-
#initialize(options) ⇒ Base
constructor
A new instance of Base.
- #next_player_move ⇒ Object
- #side_class(square) ⇒ Object
Constructor Details
#initialize(options) ⇒ Base
Returns a new instance of Base.
15 16 17 18 |
# File 'lib/ttt/interfaces/rails/app/presenters/web_game_presenter.rb', line 15 def initialize() self.board = .fetch :board self.id = .fetch :id end |
Instance Attribute Details
#board ⇒ Object
Returns the value of attribute board.
20 21 22 |
# File 'lib/ttt/interfaces/rails/app/presenters/web_game_presenter.rb', line 20 def board board.board[] end |
#id ⇒ Object
Returns the value of attribute id.
41 42 43 |
# File 'lib/ttt/interfaces/rails/app/presenters/web_game_presenter.rb', line 41 def id @id end |
Instance Method Details
#generate_form(index) ⇒ Object
37 38 39 |
# File 'lib/ttt/interfaces/rails/app/presenters/web_game_presenter.rb', line 37 def generate_form(index) %Q(<form id="#{index}" class="untaken_square" accept-charset="UTF-8" action="/ttt_games/#{id}/update_game" method="post"><input type="hidden" name="move" value="#{index}"></form>) end |
#next_player_move ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/ttt/interfaces/rails/app/presenters/web_game_presenter.rb', line 29 def next_player_move if TTT::Context.instance.ai_move?(id) "ai" else "human" end end |
#side_class(square) ⇒ Object
24 25 26 27 |
# File 'lib/ttt/interfaces/rails/app/presenters/web_game_presenter.rb', line 24 def side_class(square) return 'x_taken_square' if square == "x" 'o_taken_square' end |