Module: ADSP::Stream::WriterHelpers::ClassMethods

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

Overview

Additional class methods for writer.

Instance Method Summary collapse

Instance Method Details

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

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



80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/adsp/stream/writer_helpers.rb', line 80

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

  ::File.open file_path, "wb" do |io|
    writer = new io, *args

    begin
      yield writer
    ensure
      writer.close
    end
  end
end