Sha256: 7db809aa87fc79121b621aaf6ef86c63f63582563b3c68be1da37cd0c585a5ad

Contents?: true

Size: 566 Bytes

Versions: 3

Compression:

Stored size: 566 Bytes

Contents

class Fourtrack::Player
  def initialize(io)
    @io = io
  end

  def readlines
    [].tap {|o|  each_line{|line| o << line }}
  end

  def each_line(&blk)
    # https://github.com/exAspArk/multiple_files_gzip_reader
    # https://bugs.ruby-lang.org/issues/9790
    loop do
      break if @io.eof?
      zr = Zlib::GzipReader.new(@io)
      zr.each_line(&blk)
      unused_bytestr = zr.unused
      zr.finish
      if unused_bytestr && unused_bytestr.bytesize.nonzero?
        @io.pos -= unused_bytestr.bytesize
      else
        break
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fourtrack-0.2.1 lib/fourtrack/player.rb
fourtrack-0.2.0 lib/fourtrack/player.rb
fourtrack-0.1.0 lib/fourtrack/player.rb