Sha256: a73036093693bfb451510cfb747f7bc94dc971ecc71ee2a73a32c39704a45b41
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
=INFORMATION Author: Aldric Giacomoni Email : aldric@at@trevoke.net (feedback very welcome!) SGF: all formats (but untested with FF < 4) Ruby: >=1.8.7 (may work with 1.8.6) =QUICK HOWTO Example: require 'sgf' tree = SGF::Parser.new file_or_string All trees begin with an empty node ( @root) which allows a simple support of multiple gametrees. Most games will just care about, say, tree.root.children[0] which is the first node of the first gametree. For any node, one can summon the properties as such: node.properties # => returns a hash of the properties. A single property can be called, like the comments, for instance, like so: node.C # => returns the comments for this node. node.comments # => syntactic sugar The library currently uses method_missing to painlessly return the data. I must admit that this is both clever coding and laziness on my part. There is also a SGF Indenter. Its purpose is to make SGF files more readable to humans at a glance. require 'sgf/sgfindent' # Done automatically if you require 'sgf_parser' sgf = SGF::Indenter.new 'some_ugly_file.sgf' # Will output to the console sgf = SGF::Indenter.new 'some_ugly_file.sgf' 'pretty.sgf' # Sends the result to a new file. ___ TODO - Create a "Game" class that wraps a complete set of () for ease of use - implement node.next to go to node.children[0] because who wants to type that anyway? - implement a 'current' node in Tree so we don't have to jump from node to node. This means.. - implement tree.next instead of node.next for tree.current_node.children[0] - examine/fix the smell that when you use add_children, it also sets the parent on the passed-in nodes. - fix the multiple properties bug in the SGF indenter as well - see how much of the parser code the indenter can use, since it's basically the same logic
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
SgfParser-1.0.0 | README.rdoc |