Class: WebGamePresenter::FourByFour
- Defined in:
- lib/ttt/interfaces/rails/app/presenters/web_game_presenter.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#generate_form, #initialize, #next_player_move, #side_class
Constructor Details
This class inherits a constructor from WebGamePresenter::Base
Instance Method Details
#show_board ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/ttt/interfaces/rails/app/presenters/web_game_presenter.rb', line 74 def show_board html_string = "<table class='four_by_four'><tr>" board[].each_with_index do |square, index| html_string += "</tr><tr>" if index % 4 == 0 && index != 0 if square == " " html_string += %Q(#{generate_form(index) unless board.finished?}<td value="#{index}" class="square #{next_player_move} #{square_class(index)}"></td>) else html_string += %Q(<td id="#{index}" class="square #{side_class(square)} #{square_class(index)}">#{square}</td>) end end html_string += "</tr></table>" end |
#square_class(index) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ttt/interfaces/rails/app/presenters/web_game_presenter.rb', line 87 def square_class(index) html_class = case index when 0 then 'top_left' when 1 then 'top_middle' when 2 then 'top_middle' when 3 then 'top_right' when 4 then 'middle_left' when 5 then 'middle' when 6 then 'middle' when 7 then 'middle_right' when 8 then 'middle_left' when 9 then 'middle' when 10 then 'middle' when 11 then 'middle_right' when 12 then 'bottom_left' when 13 then 'bottom_middle' when 14 then 'bottom_middle' when 15 then 'bottom_right' end end |