Class: Gedcom
- Inherits:
-
Object
- Object
- Gedcom
- Defined in:
- lib/gedcom.rb
Overview
require 'chart.rb'
Constant Summary collapse
- VERSION =
'0.9.4'
Instance Attribute Summary collapse
-
#transmissions ⇒ Object
Returns the value of attribute transmissions.
Class Method Summary collapse
Instance Method Summary collapse
- #add_transmission(transmission) ⇒ Object
- #each ⇒ Object
- #file(*args) ⇒ Object
-
#initialize(transmission = nil) ⇒ Gedcom
constructor
A new instance of Gedcom.
- #read(io) ⇒ Object
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
#transmissions ⇒ Object
Returns the value of attribute transmissions.
63 64 65 |
# File 'lib/gedcom.rb', line 63 def transmissions @transmissions end |
Class Method Details
Instance Method Details
#add_transmission(transmission) ⇒ Object
104 105 106 |
# File 'lib/gedcom.rb', line 104 def add_transmission(transmission) @transmissions << transmission end |
#each ⇒ Object
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 |