Module: PGN

Defined in:
lib/pgn3.rb,
lib/pgn/fen.rb,
lib/pgn/game.rb,
lib/pgn/move.rb,
lib/pgn/board.rb,
lib/pgn/parser.rb,
lib/pgn/version.rb,
lib/pgn/position.rb,
lib/pgn/move_calculator.rb

Defined Under Namespace

Classes: Board, FEN, Game, Move, MoveCalculator, MoveText, Parser, Position

Constant Summary collapse

VERSION =
'0.0.5'.freeze

Class Method Summary collapse

Class Method Details

.parse(pgn, encoding = Encoding::ISO_8859_1) ⇒ Array<PGN::Game>

Note:

The PGN spec specifies Latin-1 as the encoding for PGN files, so this is default.

Returns a list of games.

Parameters:

  • pgn (String)

    a pgn representation of one or more chess games

Returns:

See Also:



19
20
21
22
23
24
25
# File 'lib/pgn3.rb', line 19

def self.parse(pgn, encoding = Encoding::ISO_8859_1)
  pgn.force_encoding(encoding) if encoding

  PGN::Parser.new.parse(pgn).map do |game|
    PGN::Game.new(game[:moves], game[:tags], game[:result], game[:pgn], game[:comment])
  end
end