lib/pgn2fen.rb
##
# check to verify PGN includes only a single game
check to verify PGN includes only a single game
check to verify PGN includes only a single game
def is_single_game
      count = @pgn_data.scan(/\[Event /).count
        if count > 1; return false; end
        count = @pgn_data.scan(/1-0/).count
        if count > 2; return false; end
        count = @pgn_data.scan(/0-1/).count
        if count > 2; return false; end
        count = @pgn_data.scan(/1\/2-1\/2/).count
        if count > 2; return false; end
        true
    end
def is_single_game count = @pgn_data . scan ( / \[ Event  / ) . count if count > 1 ; return false ; end count = @pgn_data . scan ( / 1-0 / ) . count if count > 2 ; return false ; end count = @pgn_data . scan ( / 0-1 / ) . count if count > 2 ; return false ; end count = @pgn_data . scan ( / 1 \/ 2-1 \/ 2 / ) . count if count > 2 ; return false ; end true end
check to verify PGN includes only a single game
check to verify PGN includes only a single game
#puts "Event count:#{count}" # result header also includes result, hence compare with 2 #puts "1-0 count:#{count}" #puts "0-1 count:#{count}" #puts "1/2-1/2 count:#{count}"