Module: PGN
- Defined in:
- lib/pgn.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.4.0'.freeze
Class Method Summary collapse
-
.parse(pgn, encoding = Encoding::ISO_8859_1) ⇒ Array<PGN::Game>
A list of games.
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.
19 20 21 22 23 24 25 |
# File 'lib/pgn.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 |