69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/chem/db/msi.rb', line 69
def read
current = MSIFile.new
@top = current
@input.each_line do |l|
if /\((\d+) (\S+)/ =~ l
case $2
when 'Model'
current.child = Model.new($1)
current = current.child
when 'Atom'
current.child = MSIAtom.new($1)
current = current.child
when 'Bond'
current.child = MSIBond.new($1)
current = current.child
end
@objects[$1.to_i] = current
elsif /\(A (\S) (\S+) (.+)\)/ =~ (l)
case $1
when 'C'
current.prop[$2] = $3
when 'I'
current.prop[$2] = $3.to_i
when 'O'
current.prop[$2] = @objects[$3.to_i]
when 'D'
current.prop[$2] = $3.scanf("(%f %f %f")
end
elsif /\s+\)/ =~ l
current = current.parent
end
end
end
|