Sha256: 2cab4e83bc92c3c8b3b883f1c61d435cc627da042afd52dacc962c7ae10f5c05
Contents?: true
Size: 743 Bytes
Versions: 3
Compression:
Stored size: 743 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('../sample_sgf/*').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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
SgfParser-0.9.1 | sample_usage/parsing_files.rb |
SgfParser-0.9.0 | sample_usage/parsing_files.rb |
SgfParser-0.8.0 | sample_usage/parsing_files.rb |