Sha256: 32726cd95a02cf97b87198406c27faed5bb407b61a06dd5b0960aa7ae4c06416

Contents?: true

Size: 771 Bytes

Versions: 1

Compression:

Stored size: 771 Bytes

Contents

module TTT
  class BoardPresenterTerminal
    attr_reader :board

    def present_board(board)
      @board = board
      #board.display_values will return multidimensional array
      display_values.each_with_index do |row, row_number|
        row.each_with_index do |display_value, index|
          #http://www.evc-cit.info/cit020/beginning-programming/chp_04/file_printf.html
          printf "%2s", display_value
          print " | " unless index == (row.size - 1)
        end
        print "\n"
        #row_number starts at 0
        puts "_"*(row.size * 5) unless row_number.equal? (number_of_rows_cols - 1)
      end
    end

    def display_values
      board.display_values
    end

    def number_of_rows_cols
      board.number_of_rows_cols
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
games_bfox-0.6.0 lib/games/tictactoe/board_presenter_terminal.rb