asciinema.org/app/models/stdout.rb

29 lines
539 B
Ruby
Raw Normal View History

class Stdout
include Enumerable
attr_reader :data_path, :timing_path
def initialize(data_path, timing_path)
@data_path = data_path
@timing_path = timing_path
end
def each
File.open(data_path, 'rb') do |file|
File.foreach(timing_path) do |line|
yield(*delay_and_data_for_line(file, line))
2013-08-13 17:27:02 +00:00
end
end
end
private
def delay_and_data_for_line(file, line)
delay, size = TimingParser.parse_line(line)
data = file.read(size).to_s.force_encoding('utf-8')
[delay, data]
end
end