Class: Zappa::SubChunkHeader
- Inherits:
-
Object
- Object
- Zappa::SubChunkHeader
- Defined in:
- lib/zappa/wave/sub_chunk_header.rb
Instance Attribute Summary collapse
-
#chunk_id ⇒ Object
Returns the value of attribute chunk_id.
-
#chunk_size ⇒ Object
Returns the value of attribute chunk_size.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(data = nil) ⇒ SubChunkHeader
constructor
A new instance of SubChunkHeader.
- #pack ⇒ Object
- #unpack(data) ⇒ Object
Constructor Details
#initialize(data = nil) ⇒ SubChunkHeader
Returns a new instance of SubChunkHeader.
5 6 7 8 9 |
# File 'lib/zappa/wave/sub_chunk_header.rb', line 5 def initialize(data = nil) @chunk_id = nil @chunk_size = 0 unpack(data) if data end |
Instance Attribute Details
#chunk_id ⇒ Object
Returns the value of attribute chunk_id.
3 4 5 |
# File 'lib/zappa/wave/sub_chunk_header.rb', line 3 def chunk_id @chunk_id end |
#chunk_size ⇒ Object
Returns the value of attribute chunk_size.
3 4 5 |
# File 'lib/zappa/wave/sub_chunk_header.rb', line 3 def chunk_size @chunk_size end |
Instance Method Details
#==(other) ⇒ Object
20 21 22 |
# File 'lib/zappa/wave/sub_chunk_header.rb', line 20 def ==(other) other.chunk_size == @chunk_size && other.chunk_id = @chunk_id end |
#pack ⇒ Object
11 12 13 |
# File 'lib/zappa/wave/sub_chunk_header.rb', line 11 def pack @chunk_id + [@chunk_size].pack('V') end |
#unpack(data) ⇒ Object
15 16 17 18 |
# File 'lib/zappa/wave/sub_chunk_header.rb', line 15 def unpack(data) @chunk_id = data.byteslice(0, 4) @chunk_size = data.byteslice(4, 4).unpack('V').first end |