Class: ThreadStackExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/threadStackExtractor.rb

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ ThreadStackExtractor

Returns a new instance of ThreadStackExtractor.



3
4
5
# File 'lib/threadStackExtractor.rb', line 3

def initialize(file)
	@file = file
end

Instance Method Details

#getThreadStacksObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/threadStackExtractor.rb', line 7

def getThreadStacks
	stacks = Array.new()

	stack = Array.new()
	while (line = @file.gets)
     encoded = line.encode('UTF-8', 'UTF-8', { :invalid => :replace })
		case encoded
			when /^3XMTHREADINFO\s*(.*)/ then
				stacks << stack unless stack.empty?
				stack = Array.new()	
			when /^4XESTACKTRACE\s*(.*)/ then
				stack << $1
		end
	end
	stacks << stack unless stack.empty?

	return stacks
end