Class: Dsu::Services::TempFile::ReaderService
- Inherits:
-
Object
- Object
- Dsu::Services::TempFile::ReaderService
- Defined in:
- lib/dsu/services/temp_file/reader_service.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(tmp_file_path:, options: {}) ⇒ ReaderService
constructor
A new instance of ReaderService.
Constructor Details
#initialize(tmp_file_path:, options: {}) ⇒ ReaderService
Returns a new instance of ReaderService.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dsu/services/temp_file/reader_service.rb', line 7 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 .nil? raise ArgumentError, 'options is the wrong object type' unless .is_a?(Hash) @tmp_file_path = tmp_file_path @options = || {} end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/dsu/services/temp_file/reader_service.rb', line 19 def call raise ArgumentError, 'no block given' unless block_given? File.foreach(tmp_file_path) do |line| yield line.strip end end |