asciinema.org/app/models/stdout.rb

31 lines
586 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|
2013-08-13 17:27:02 +00:00
delay, size = TimingParser.parse_line(line)
yield(delay, file.read(size).force_encoding('utf-8'))
end
end
end
2013-08-13 17:27:02 +00:00
def each_until(seconds)
time = 0
2013-08-13 17:27:02 +00:00
each do |delay, frame_data|
time += delay
break if time > seconds
2013-08-13 17:27:02 +00:00
yield(delay, frame_data)
end
end
end