Module: ADSP::Stream::ReaderHelpers::ClassMethods

Defined in:
lib/adsp/stream/reader_helpers.rb

Overview

Additional class methods for reader.

Instance Method Summary collapse

Instance Method Details

#open(file_path, *args, &block) ⇒ Object

Opens file_path in binary mode, creates reader and yields it.



197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/adsp/stream/reader_helpers.rb', line 197

def open(file_path, *args, &block)
  Validation.validate_string file_path
  Validation.validate_proc block

  ::File.open file_path, "rb" do |io|
    reader = new io, *args

    begin
      yield reader
    ensure
      reader.close
    end
  end
end