Class: PGN::Parser
- Inherits:
-
Object
- Object
- PGN::Parser
- Defined in:
- lib/pgn/parser.rb
Overview
Parser is the public entry point for parsing PGN text into a list of game hashes. It delegates to a concrete backend parser (currently the stdlib Racc + StringScanner parser PgnParser).
The backend class attribute is retained so callers (tests, benchmarks)
can substitute an alternative parser responding to new.parse(pgn_string).
Class Attribute Summary collapse
-
.backend ⇒ Class
The backend parser class used by parse.
Instance Method Summary collapse
-
#parse(input) ⇒ Array<Hash>
One Hash per game, with keys
:tags,:result,:moves,:pgn,:comment.
Class Attribute Details
.backend ⇒ Class
The backend parser class used by PGN.parse.
14 15 16 |
# File 'lib/pgn/parser.rb', line 14 def backend @backend end |
Instance Method Details
#parse(input) ⇒ Array<Hash>
Returns one Hash per game, with keys :tags, :result,
:moves, :pgn, :comment.
24 25 26 |
# File 'lib/pgn/parser.rb', line 24 def parse(input) self.class.backend.new.parse(input) end |