Class: Object

Inherits:
BasicObject
Defined in:
ext/fipdf/src/fachinfo_writer.rb

Constant Summary collapse

@@obj_path_id =
0

Instance Method Summary collapse

Instance Method Details

#dump_bigvars(offset = '') ⇒ Object



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

#obj_path(id, obj_path_id = nil) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'ext/fipdf/src/fachinfo_writer.rb', line 51

def obj_path(id, obj_path_id=nil)
	if(obj_path_id.nil?)
		obj_path_id = @@obj_path_id += 1
	end
	return if(frozen? || @obj_path_id == obj_path_id)
	@obj_path_id = obj_path_id
	instance_variables.each { |name|
		var = instance_variable_get(name)
		if(var.__id__ == id)
			return [name]
		end
	}
	instance_variables.each { |name|
		var = instance_variable_get(name)
		if(path = var.obj_path(id, obj_path_id))
			path.unshift(name)
			return path
		end
	}
	nil
end