Class: Shelr::TTYRec
- Inherits:
-
Object
- Object
- Shelr::TTYRec
- Defined in:
- lib/shelr/ttyrec.rb
Instance Method Summary collapse
-
#initialize(ttyrec) ⇒ TTYRec
constructor
A new instance of TTYRec.
- #parse ⇒ Object
- #to_typescript ⇒ Object
Constructor Details
#initialize(ttyrec) ⇒ TTYRec
Returns a new instance of TTYRec.
4 5 6 7 |
# File 'lib/shelr/ttyrec.rb', line 4 def initialize(ttyrec) @io = ttyrec @timeline = [] end |
Instance Method Details
#parse ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/shelr/ttyrec.rb', line 9 def parse while !@io.eof? frame = {} sec, usec, len = @io.read(12).unpack('VVV') data = @io.read(len) ||= [ sec, usec ].join('.').to_f = [ sec, usec ].join('.').to_f offset = - frame = { :offset => "%5.6f" % offset, :data => data, :length => len } @timeline << frame = prev_data = data end self end |
#to_typescript ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/shelr/ttyrec.rb', line 36 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 |