Sha256: 79a25b49b66b4f8f9484c23fdb078b62df28902a11218041507d5562a888d820
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 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_parser' tree = SgfParser::Tree.new :filename => File tree = SgfParser::Tree.new :string => 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. 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_parser/sgfindent' # Done automatically if you require 'sgf_parser' sgf = SgfParser::Indenter.new 'some_ugly_file.sgf' # Will output to the console sgf = SgfParser::Indenter.new 'some_ugly_file.sgf' 'pretty.sgf' # Sends the result to a new file. ___ TODO ? Create a "Game" class, and if a whole set of () exists, then I have a game? That way maybe I can easily go to multiple games stored in a single SGF file? Mostly syntactic sugar, but may be worth implementing.
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
SgfParser-0.9.1 | README.rdoc |
SgfParser-0.9.0 | README.rdoc |