Class: WaveFile::ChunkReaders::RiffReader::RiffChunkReader

Inherits:
BaseChunkReader
  • Object
show all
Defined in:
lib/wavefile/chunk_readers/header_reader.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from BaseChunkReader

#raise_error, #read_chunk_size

Constructor Details

#initialize(file) ⇒ RiffChunkReader

Returns a new instance of RiffChunkReader.



80
81
82
# File 'lib/wavefile/chunk_readers/header_reader.rb', line 80

def initialize(file)
  @file = file
end

Instance Method Details

#readObject



84
85
86
87
88
89
90
91
# File 'lib/wavefile/chunk_readers/header_reader.rb', line 84

def read
  chunk_size = read_chunk_size
  riff_format = @file.sysread(4)

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