Class: Gedcom

Inherits:
Object
  • Object
show all
Defined in:
lib/gedcom.rb

Overview

require 'chart.rb'

Constant Summary collapse

VERSION =
'0.9.4'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transmission = nil) ⇒ Gedcom

Returns a new instance of Gedcom.



65
66
67
68
# File 'lib/gedcom.rb', line 65

def initialize(transmission = nil)
  @transmissions = []
  add_transmission(transmission) if transmission != nil
end

Instance Attribute Details

#transmissionsObject

Returns the value of attribute transmissions.



63
64
65
# File 'lib/gedcom.rb', line 63

def transmissions
  @transmissions
end

Class Method Details

.file(*args) ⇒ Object



70
71
72
73
74
# File 'lib/gedcom.rb', line 70

def self.file(*args)
  g = Gedcom.new
  g.file(*args)
  return g
end

.read(io) ⇒ Object



82
83
84
85
86
# File 'lib/gedcom.rb', line 82

def self.read(io)
  g = Gedcom.new
  g.read(io)
  return g
end

Instance Method Details

#add_transmission(transmission) ⇒ Object



104
105
106
# File 'lib/gedcom.rb', line 104

def add_transmission(transmission)
  @transmissions << transmission
end

#eachObject



108
109
110
# File 'lib/gedcom.rb', line 108

def each
  @transmissions.each { |t| yield t }
end

#file(*args) ⇒ Object



76
77
78
79
80
# File 'lib/gedcom.rb', line 76

def file(*args)
  File.open(*args) do |file|
    read(file)
  end
end

#read(io) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/gedcom.rb', line 88

def read(io)
  transmission = Transmission.new
  gedcom_parser = GedcomParser.new(transmission)
  
  io.each_line("\n") do |line|
    begin
      gedcom_parser.parse( io.lineno, line )
    rescue => exception
      puts "#{io.lineno}: #{exception} - " + line
      # raise exception
    end
  end
  
  @transmissions << transmission
end