Class: WaveFile::ChunkReaders::RiffChunkReader

Inherits:
BaseChunkReader show all
Defined in:
lib/wavefile/chunk_readers/riff_chunk_reader.rb

Overview

Internal

Instance Method Summary collapse

Methods inherited from BaseChunkReader

#raise_error

Constructor Details

#initialize(io, chunk_size) ⇒ RiffChunkReader

:nodoc:



5
6
7
8
# File 'lib/wavefile/chunk_readers/riff_chunk_reader.rb', line 5

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

Instance Method Details

#readObject



10
11
12
13
14
15
16
# File 'lib/wavefile/chunk_readers/riff_chunk_reader.rb', line 10

def read
  riff_format = @io.sysread(4)

  unless riff_format == WAVEFILE_FORMAT_CODE
    raise_error InvalidFormatError, "Expected RIFF format of '#{WAVEFILE_FORMAT_CODE}', but was '#{riff_format}'"
  end
end