Class: BMFF::Box::Base
- Inherits:
-
Object
- Object
- BMFF::Box::Base
- Defined in:
- lib/bmffglitch/bmffex.rb
Instance Attribute Summary collapse
-
#raw_data ⇒ Object
Returns the value of attribute raw_data.
Instance Method Summary collapse
Instance Attribute Details
#raw_data ⇒ Object
Returns the value of attribute raw_data.
14 15 16 |
# File 'lib/bmffglitch/bmffex.rb', line 14 def raw_data @raw_data end |
Instance Method Details
#compose(data) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bmffglitch/bmffex.rb', line 15 def compose(data) # size(uint32) + type(uint32) size = 4 + 4 if @type == 'uuid' # extended_type(uint8[16]) size += 16 end # 8 is the size of largesize(uint64) if size + 8 + data.length > 0xffffffff largesize = size + 8 + data.length size = 1 else size += data.length end sio = StringIO.new("", "r+") sio.set_encoding("ascii-8bit") sio.extend(BMFF::BinaryAccessor) sio.write_uint32(size) sio.write_ascii(@type) sio.write_uint64(largesize) if size == 1 sio.write_uuid(@usertype) if @type == 'uuid' return sio.string + data end |
#parse_data ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/bmffglitch/bmffex.rb', line 41 def parse_data data_start_pos = @io.pos seek_to_end data_end_pos = @io.pos @io.pos = data_start_pos @raw_data = @io.read(data_end_pos - data_start_pos) @io.pos = data_start_pos end |
#to_s ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/bmffglitch/bmffex.rb', line 50 def to_s if container? compose(@children.map {|box| box.to_s}.join) else compose(@raw_data) end end |