Hosted at
SourceForge.net Logo
GEDCOM/Ruby Module

[ Project Page / Downloads / CVS ]

GEDCOM/Ruby

The GEDCOM/Ruby library is an interface for allowing Ruby programs to parse GEDCOM data files. It defines a very flexible, non-validating callback parser, as well as a powerful Date class for parsing GEDCOM standard dates.

Example

Here's an example of how to use the module:

           1  #!/usr/bin/ruby
           2
           3  require 'gedcom'
           4
           5  class Counter
           6    attr_reader :count
           7
           8    def initialize
           9      @count = 0
          10    end
          11
          12    def increment
          13      @count += 1
          14    end
          15  end
          16
          17  def count_person( data, cookie, parm )
          18    cookie.increment
          19  end
          20
          21  counter = Counter.new
          22  parser = GEDCOM::Parser.new( counter )
          23
          24  parser.setPreHandler [ "INDI" ], method( :count_person )
          25
          26  parser.parse( "myfam.ged" )
          27
          28  puts "#{counter.count} individuals in the file"
    

-- Jamis Buck (jgb3 at email.byu.edu)