Sha256: 4340130700a8dac149e5b15d6eb4bb63eca09f2421d9e7795dd2cb6e544ed222
Contents?: true
Size: 719 Bytes
Versions: 1
Compression:
Stored size: 719 Bytes
Contents
# With this code, we will display info on all files within a directory: # "Black_player-White_player.sgf" require '../lib/sgf_parser' Dir.glob('../data/*').each do |file| next if File.directory? file # Let's not touch directories. next if File.extname(file) != ".sgf" # If it's not an SGF file, let's not touch it. sgf = SgfParser::Tree.new :filename => file # The "root" is an empty node, always, so we can support SGF collections painlessly: # Whole trees simply become branches from the root. black = sgf.root.children[0].PB rescue "Black" # Alright, so this isn't particularly elegant. white = sgf.root.children[0].PW rescue "White" # It's a work in progress ! puts "#{black}-#{white}.sgf" end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
SgfParser-1.0.0 | sample_usage/parsing_files.rb |