Class: View::Board

Inherits:
Base
  • Object
show all
Defined in:
lib/tic_tac_toe/view/board.rb

Instance Method Summary collapse

Methods inherited from Base

#display_msg

Constructor Details

#initialize(board_presenter, table_klass) ⇒ Board

Returns a new instance of Board.



3
4
5
6
# File 'lib/tic_tac_toe/view/board.rb', line 3

def initialize(board_presenter, table_klass)
  @board_presenter = board_presenter
  @table_klass = table_klass
end

Instance Method Details

#renderObject



8
9
10
11
12
13
14
15
# File 'lib/tic_tac_toe/view/board.rb', line 8

def render
  tile_collection = @board_presenter.tile_collection
  headings = generate_headings(tile_collection.dimensions)
  rows = format_rows(tile_collection.rows)
  table = @table_klass.new(headings: headings, rows: rows, style: { all_separators: true })

  display_msg(table)
end