Method: ChessRB::Position#to_s

Defined in:
lib/chess_rb/position.rb

#to_s(dark_background = true) ⇒ Object



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/chess_rb/position.rb', line 169

def to_s(dark_background = true)
  str = ""
  @board.each_with_index do |r, i|
    str += (8 - i).to_s + ""
    r.each do |s|
      str += " "
      if s == 0
        str += ""
      else
        str += ChessRB::Piece.new(s).to_s(dark_background)
      end
    end
    str += "\n"
  end
  str += " ╚════════════════\n   A B C D E F G H"
  return str
end