class ReadLog

Public Class Methods

new(fn) click to toggle source
   # File lib/roma/tools/log_merger.rb
 5 def initialize(fn)
 6   @f = open(fn)
 7   @buff = ''
 8   @prev = @f.gets
 9   @s_date = ''
10 end

Public Instance Methods

get_date() click to toggle source
   # File lib/roma/tools/log_merger.rb
38 def get_date
39   @s_date
40 end
get_line() click to toggle source
   # File lib/roma/tools/log_merger.rb
34 def get_line
35   @buff
36 end
match_line(l) click to toggle source
   # File lib/roma/tools/log_merger.rb
42 def match_line(l)
43   if /^[TDIWEFU],\s\[(\d{4})\-(\d{2})\-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.(\d+)\s#\d+\].+/ =~ l then
44     @s_date = $1 << $2 << $3 << $4 << $5 << $6 << $7
45     true
46   else
47     @s_date = nil
48     false
49   end
50 end
read_line() click to toggle source
   # File lib/roma/tools/log_merger.rb
12 def read_line
13   begin
14     if /^#\sLogfile\screated\son.+/ =~ @prev then
15       @prev = @f.gets
16     end
17 
18     @buff = @prev
19     @prev = @f.gets
20 
21     while !(match_line(@prev)) && !(@prev.nil?) do
22       @buff << @prev
23       @prev = @f.gets
24     end
25 
26     match_line(@buff)
27   rescue
28     unless @f.closed?
29       @f.close
30     end
31   end
32 end