Sha256: 8d36b299f2a88a73f3ee1ee8fb08397ec5690bd4d3987ad15ba1a06ae9e3007d
Contents?: true
Size: 621 Bytes
Versions: 1
Compression:
Stored size: 621 Bytes
Contents
class Tracksperanto::Accumulator < DelegateClass(IO) attr_reader :numt def initialize __setobj__(Tracksperanto::BufferIO.new) @numt = 0 end def call(with_arrived_tracker) @numt += 1 d = Marshal.dump(with_arrived_tracker) bytelen = d.size write(bytelen) write("\t") write(d) write("\n") end def each_object_with_index rewind @numt.times { |i| yield(recover_tracker, i - 1) } end private def recover_tracker # Read everything upto the tab demarshal_bytes = gets("\t").strip.to_i Marshal.load(read(demarshal_bytes)) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tracksperanto-1.9.9 | lib/tracksperanto/accumulator.rb |