2013-08-04 20:43:36 +00:00
|
|
|
class Stdout
|
|
|
|
include Enumerable
|
|
|
|
|
2013-08-15 18:58:41 +00:00
|
|
|
attr_reader :data_path, :timing_path
|
2013-08-04 20:43:36 +00:00
|
|
|
|
2013-08-15 18:58:41 +00:00
|
|
|
def initialize(data_path, timing_path)
|
|
|
|
@data_path = data_path
|
|
|
|
@timing_path = timing_path
|
2013-08-04 20:43:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def each
|
2013-08-15 18:58:41 +00:00
|
|
|
File.open(data_path, 'rb') do |file|
|
|
|
|
File.foreach(timing_path) do |line|
|
2013-08-29 14:37:56 +00:00
|
|
|
yield(*delay_and_data_for_line(file, line))
|
2013-08-13 17:27:02 +00:00
|
|
|
end
|
2013-08-04 20:43:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-08-29 14:37:56 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def delay_and_data_for_line(file, line)
|
|
|
|
delay, size = TimingParser.parse_line(line)
|
2013-09-20 20:37:05 +00:00
|
|
|
data = file.read(size).to_s.force_encoding('utf-8')
|
2013-08-29 14:37:56 +00:00
|
|
|
|
|
|
|
[delay, data]
|
|
|
|
end
|
|
|
|
|
2013-08-04 20:43:36 +00:00
|
|
|
end
|