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
49
|
# File 'ext/fipdf/src/fachinfo_writer.rb', line 19
def dump_bigvars(offset = '')
unless($dumped_ids.include? self.__id__)
$dumped_ids << self.__id__
line = [
self.class,
self.__id__,
(Marshal.dump(self).size/1024).to_s << 'K'
].join(':')
vars = instance_variables.collect { |name|
[name, instance_variable_get(name)]
}
if(is_a?(Array))
each_with_index { |item, idx|
vars << [idx.to_s, item]
}
elsif(is_a?(Hash))
each { |key, item|
vars << [key.to_s, item]
}
end
bigvars = vars.sort_by { |name, item|
Marshal.dump(item).size
}.reverse[0,5]
final = bigvars.collect { |name, var|
offset.to_s + name.to_s + var.dump_bigvars(offset.to_s + ' ').to_s
}.unshift(offset.to_s + line.to_s)
"\n" << final.join("\n")
else
":" << self.class.to_s << ":" << self.__id__.to_s
end
end
|