Method: ChessGame#read
- Defined in:
- lib/bangkok/chessgame.rb
#read(io) ⇒ Object
Read the chess game. Set player names and return a string containing the chess moves (“1. f4 Nf6 2. Nf3 c5…”).
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bangkok/chessgame.rb', line 26 def read(io) game_text = '' io.each { | line | line.chomp! case line when /\[(.*)\]/ # New games starting (if multi-game file) when /^\s*$/ else game_text << ' ' game_text << line end } game_text end |