Sha256: 49cfa4b943bca149250ae7ff1afa3ae54d74669dbafe166982732203ba892a00

Contents?: true

Size: 1.02 KB

Versions: 48

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Dsu
  module Services
    module TempFile
      class ReaderService
        def initialize(tmp_file_path:, options: {})
          raise ArgumentError, 'tmp_file_path is nil' if tmp_file_path.nil?
          raise ArgumentError, 'tmp_file_path is the wrong object type' unless tmp_file_path.is_a?(String)
          raise ArgumentError, 'tmp_file_path is empty' if tmp_file_path.empty?
          raise ArgumentError, 'tmp_file_path does not exist' unless File.exist?(tmp_file_path)
          raise ArgumentError, 'options is nil' if options.nil?
          raise ArgumentError, 'options is the wrong object type' unless options.is_a?(Hash)

          @tmp_file_path = tmp_file_path
          @options = options || {}
        end

        def call
          raise ArgumentError, 'no block given' unless block_given?

          File.foreach(tmp_file_path) do |line|
            yield line.strip
          end
        end

        private

        attr_reader :tmp_file_path, :options
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
dsu-3.0.5 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.4 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.3 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.1 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0.beta.3 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0.beta.2 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0.beta.1 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0.beta.0 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0.alpha.12 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0.alpha.11 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0.alpha.10 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0.alpha.9 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0.alpha.8 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0.alpha.7 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0.alpha.6 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0.alpha.5 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0.alpha.4 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0.alpha.3 lib/dsu/services/temp_file/reader_service.rb
dsu-3.0.0.alpha.2 lib/dsu/services/temp_file/reader_service.rb