Sha256: 60097947e76f9b83dbe1204eabf48f423f7cc25336c8ff52941c10afb43b2426

Contents?: true

Size: 758 Bytes

Versions: 2

Compression:

Stored size: 758 Bytes

Contents

module TTT
  class BoardPresenterTerminal
    attr_accessor :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 - 1)
      end
    end

    def display_values
      board.display_values
    end

    def number_of_rows
      board.number_of_rows
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
games_bfox-0.3.0 lib/games/tictactoe/board_presenter_terminal.rb
games_bfox-0.2.0 lib/games/tictactoe/board_presenter_terminal.rb