lib/chess/board.rb
# Returns a stringifed version of the board
Returns a stringifed version of the board
Returns a stringifed version of the board
def to_s
      board = "\n"
      background = [248,250,210]
      @state.reverse.each_with_index do |row, i|
        board += "#{(8 - i)} "
        row.each do |square|
          if square == nil
            board += Paint["   ", nil, background]
          else
            board += Paint[" #{square.symbol} ", nil, background]
          end
          background = switch_background(background)
        end
        board += "\n"
        background = switch_background(background)
      end
      board += "   a  b  c  d  e  f  g  h "
    end
def to_s board = "\n" background = [ 248 , 250 , 210 ] @state . reverse . each_with_index do | row , i | board += "#{(8 - i)} " row . each do | square | if square == nil board += Paint [ "   " , nil , background ] else board += Paint [ " #{square.symbol} " , nil , background ] end background = switch_background ( background ) end board += "\n" background = switch_background ( background ) end board += "   a  b  c  d  e  f  g  h " end
Returns a stringifed version of the board
Returns a stringifed version of the board