Sha256: 98e40da30c44bf064ab599169f9cb84823bb5261e95d5f4b7b8df1777e41be3a
Contents?: true
Size: 976 Bytes
Versions: 33
Compression:
Stored size: 976 Bytes
Contents
module Shelr class TTYRec def initialize(ttyrec) @io = ttyrec @timeline = [] end def parse while !@io.eof? frame = {} sec, usec, len = @io.read(12).unpack('VVV') data = @io.read(len) prev_timestamp ||= [ sec, usec ].join('.').to_f curr_timestamp = [ sec, usec ].join('.').to_f offset = curr_timestamp - prev_timestamp frame = { :offset => "%5.6f" % offset, :data => data, :length => len } @timeline << frame prev_timestamp = curr_timestamp prev_data = data end self end def to_typescript script = { :typescript => "Script started...\n", :timing => "" } @timeline.each do |frame| script[:timing] += [frame[:offset], ' ', frame[:length], "\n"].join script[:typescript] += frame[:data] end script end end end
Version data entries
33 entries across 33 versions & 1 rubygems