Class: WavFile::Chunk
- Inherits:
-
Object
- Object
- WavFile::Chunk
- Defined in:
- lib/wav-file/wav-file.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#name ⇒ Object
Returns the value of attribute name.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
-
#initialize(file) ⇒ Chunk
constructor
A new instance of Chunk.
- #to_bin ⇒ Object
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
#data ⇒ Object
Returns the value of attribute data.
8 9 10 |
# File 'lib/wav-file/wav-file.rb', line 8 def data @data end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/wav-file/wav-file.rb', line 8 def name @name end |
#size ⇒ Object
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_bin ⇒ Object
16 17 18 |
# File 'lib/wav-file/wav-file.rb', line 16 def to_bin @name + [@data.size].pack('V') + @data end |