Class: WavFile::Chunk

Inherits:
Object
  • Object
show all
Defined in:
lib/wav-file/wav-file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Chunk

Returns a new instance of Chunk.



10
11
12
13
14
# File 'lib/wav-file/wav-file.rb', line 10

def initialize(file)
  @name = file.read(4)
  @size = file.read(4).unpack("V")[0].to_i
  @data = file.read(@size)
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



8
9
10
# File 'lib/wav-file/wav-file.rb', line 8

def data
  @data
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/wav-file/wav-file.rb', line 8

def name
  @name
end

#sizeObject

Returns the value of attribute size.



8
9
10
# File 'lib/wav-file/wav-file.rb', line 8

def size
  @size
end

Instance Method Details

#to_binObject



16
17
18
# File 'lib/wav-file/wav-file.rb', line 16

def to_bin
  @name + [@data.size].pack('V') + @data
end