Class: WahWah::Asf::Object

Inherits:
Object
  • Object
show all
Includes:
LazyRead
Defined in:
lib/wahwah/asf/object.rb

Overview

The base unit of organization for ASF files is called the ASF object. It consists of a 128-bit GUID for the object, a 64-bit integer object size, and the variable-length object data. The value of the object size field is the sum of 24 bytes plus the size of the object data in bytes. The following diagram illustrates the ASF object structure:

16 bytes: Object GUID 8 bytes: Object size variable-sized: Object data

Constant Summary collapse

HEADER_SIZE =
24
HEADER_FORMAT =
"a16Q<"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LazyRead

#data, prepended, #skip

Constructor Details

#initializeObject

Returns a new instance of Object.



21
22
23
24
25
26
27
# File 'lib/wahwah/asf/object.rb', line 21

def initialize
  guid_bytes, @size = @file_io.read(HEADER_SIZE)&.unpack(HEADER_FORMAT)
  return unless valid?

  @size -= HEADER_SIZE
  @guid = Helper.byte_string_to_guid(guid_bytes)
end

Instance Attribute Details

#guidObject (readonly)

Returns the value of attribute guid.



19
20
21
# File 'lib/wahwah/asf/object.rb', line 19

def guid
  @guid
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/wahwah/asf/object.rb', line 29

def valid?
  !@size.nil? && @size >= HEADER_SIZE
end