Sha256: fc81745572c14d738fa69a16d9cf3fc8a8d5804f6e302f0d886e8fba488519fd

Contents?: true

Size: 600 Bytes

Versions: 16

Compression:

Stored size: 600 Bytes

Contents

# frozen_string_literal: true

module Spandx
  module Core
    class Relation
      attr_reader :io, :index

      def initialize(io, index)
        @io = io
        @index = index
      end

      def each
        size.times do |n|
          yield row(n)
        end
      end

      def size
        index.size
      end

      def row(number)
        offset = number.zero? ? 0 : index.position_for(number)
        return unless offset

        io.seek(offset)
        parse_row(io.gets)
      end

      private

      def parse_row(line)
        CsvParser.parse(line)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
spandx-0.18.3 lib/spandx/core/relation.rb
spandx-0.18.2 lib/spandx/core/relation.rb
spandx-0.18.1 lib/spandx/core/relation.rb
spandx-0.18.0 lib/spandx/core/relation.rb
spandx-0.17.0 lib/spandx/core/relation.rb
spandx-0.16.1 lib/spandx/core/relation.rb
spandx-0.16.0 lib/spandx/core/relation.rb
spandx-0.15.1 lib/spandx/core/relation.rb
spandx-0.15.0 lib/spandx/core/relation.rb
spandx-0.14.0 lib/spandx/core/relation.rb
spandx-0.13.5 lib/spandx/core/relation.rb
spandx-0.13.4 lib/spandx/core/relation.rb
spandx-0.13.3 lib/spandx/core/relation.rb
spandx-0.13.2 lib/spandx/core/relation.rb
spandx-0.13.1 lib/spandx/core/relation.rb
spandx-0.13.0 lib/spandx/core/relation.rb