Sha256: b965c1010241e75ed647e0d8cb7e6c52d9e2a9ba60980af30555d162c52a7203

Contents?: true

Size: 797 Bytes

Versions: 52

Compression:

Stored size: 797 Bytes

Contents

#!/usr/bin/env ruby

#
#     ttyrec -a -e ./material_colours_app.rb /tmp/ttyrecord
#

ttyrecord = File.binread('/tmp/ttyrecord')
ttyrecord.force_encoding('BINARY') if ttyrecord.respond_to?(:force_encoding)

offset = 0
chunks = []

while offset < ttyrecord.size
  hash = {}

  data_start  = offset + 12
  data_length = ttyrecord[offset..(data_start)].unpack('VVV')[2]
  data_end    = data_start + data_length

  hash[:offset]       = offset
  hash[:data_start]   = data_start
  hash[:data_length]  = data_length
  hash[:data]         = ttyrecord[(data_start)...(data_end)]
  hash[:data_end]     = data_end

  chunks << hash

  offset = data_start + data_length
end

File.open('/tmp/ttyrecord_decoded', 'w') do |file|
  chunks.each do |chunk|
    file.write("---\n" + chunk[:data] + "\n")
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
vedeu-0.6.46 test/support/ttyrec.rb
vedeu-0.6.45 test/support/ttyrec.rb
vedeu-0.6.44 test/support/ttyrec.rb
vedeu-0.6.43 test/support/ttyrec.rb
vedeu-0.6.42 test/support/ttyrec.rb
vedeu-0.6.41 test/support/ttyrec.rb
vedeu-0.6.40 test/support/ttyrec.rb
vedeu-0.6.39 test/support/ttyrec.rb
vedeu-0.6.38 test/support/ttyrec.rb
vedeu-0.6.37 test/support/ttyrec.rb
vedeu-0.6.36 test/support/ttyrec.rb
vedeu-0.6.35 test/support/ttyrec.rb