Sha256: cd83279ccda46fd92333085b3cc31840e89ba1c77353869b9a56dd2ce1519a5e

Contents?: true

Size: 828 Bytes

Versions: 10

Compression:

Stored size: 828 Bytes

Contents

#!/usr/bin/env ruby

# frozen_string_literal: true

#
#     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

10 entries across 10 versions & 1 rubygems

Version Path
vedeu-0.8.21 test/support/ttyrec.rb
vedeu-0.8.20 test/support/ttyrec.rb
vedeu-0.8.19 test/support/ttyrec.rb
vedeu-0.8.18 test/support/ttyrec.rb
vedeu-0.8.17 test/support/ttyrec.rb
vedeu-0.8.16 test/support/ttyrec.rb
vedeu-0.8.15 test/support/ttyrec.rb
vedeu-0.8.14 test/support/ttyrec.rb
vedeu-0.8.13 test/support/ttyrec.rb
vedeu-0.8.12 test/support/ttyrec.rb