13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/odba/18_19_loading_compatibility.rb', line 13
def self._load(str)
scn = StringScanner.new str
a = []
while match = scn.get_byte
case match
when ":"
len = scn.get_byte
name = scn.scan /.{#{Marshal.load("\x04\bi#{len}")}}/
when "i"
int = scn.get_byte
size, = int.unpack('c')
if size > 1 && size < 5
size.times do
int << scn.get_byte
end
end
dump = "\x04\bi" << int
a.push Marshal.load(dump)
end
end
ajd = of = sg = 0
if a.size == 3
num, den, sg = a
if den > 0
ajd = Rational(num,den)
ajd -= 1.to_r/2
end
else
num, den, of, sg = a
if den > 0
ajd = Rational(num,den)
end
end
ajd += 1.to_r/2
jd(ajd)
end
|