Class: Bchess::PGN::Parser
- Inherits:
-
Object
- Object
- Bchess::PGN::Parser
- Defined in:
- lib/pgn/parser.rb
Constant Summary collapse
- @@parser =
SexpParser.new
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Instance Method Summary collapse
-
#initialize(input) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(input) ⇒ Parser
Returns a new instance of Parser.
13 14 15 |
# File 'lib/pgn/parser.rb', line 13 def initialize(input) @input = input end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
8 9 10 |
# File 'lib/pgn/parser.rb', line 8 def error @error end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
8 9 10 |
# File 'lib/pgn/parser.rb', line 8 def input @input end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
8 9 10 |
# File 'lib/pgn/parser.rb', line 8 def output @output end |
#tree ⇒ Object (readonly)
Returns the value of attribute tree.
8 9 10 |
# File 'lib/pgn/parser.rb', line 8 def tree @tree end |
Instance Method Details
#parse ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pgn/parser.rb', line 17 def parse if input.is_a?(String) @tree = @@parser.parse(input) elsif input.is_a?(Bchess::PGN::PGNFile) @tree = @@parser.parse(input.load_games) end unless tree raise PGN::ParserException, "Parse error at offset: #{@@parser.index}" end sanitize_tree(tree) end |