Sha256: 43c465aa712fe1fec8cb585534727da6608f6b8f7da267d892dfd2b432ddd896

Contents?: true

Size: 522 Bytes

Versions: 3

Compression:

Stored size: 522 Bytes

Contents

# frozen_string_literal: true

module Spandx
  module Core
    class LineIo
      def initialize(absolute_path)
        file_descriptor = IO.sysopen(absolute_path)
        @io = IO.new(file_descriptor)
        @buffer = ''
      end

      def each(&block)
        @buffer << @io.sysread(512) until @buffer.include?($INPUT_RECORD_SEPARATOR)

        line, @buffer = @buffer.split($INPUT_RECORD_SEPARATOR, 2)
        block.call(line)
        each(&block)
      rescue EOFError
        @io.close
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spandx-0.13.2 lib/spandx/core/line_io.rb
spandx-0.13.1 lib/spandx/core/line_io.rb
spandx-0.13.0 lib/spandx/core/line_io.rb