Class: Furnace::SWF::TagWrapper
- Inherits:
-
BinData::Record
- Object
- BinData::Record
- Furnace::SWF::TagWrapper
- Defined in:
- lib/furnace-swf/swf/tag_wrapper.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
Instance Method Summary collapse
- #content_size ⇒ Object
- #debug_name_of(child) ⇒ Object
- #do_num_bytes ⇒ Object
-
#do_read(io) ⇒ Object
Nested reads/writes.
- #do_write(io) ⇒ Object
- #real_length ⇒ Object
- #real_length=(value) ⇒ Object
- #short_length ⇒ Object
- #short_length=(value) ⇒ Object
-
#type ⇒ Object
Accessors for braindead format.
- #type=(value) ⇒ Object
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
8 9 10 |
# File 'lib/furnace-swf/swf/tag_wrapper.rb', line 8 def content @content end |
Instance Method Details
#content_size ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/furnace-swf/swf/tag_wrapper.rb', line 77 def content_size if @content.is_a? Tag @content.num_bytes else @content.length end end |
#debug_name_of(child) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/furnace-swf/swf/tag_wrapper.rb', line 85 def debug_name_of(child) if child.is_a?(Tag) "#{debug_name}.content" else super end end |
#do_num_bytes ⇒ Object
71 72 73 74 75 |
# File 'lib/furnace-swf/swf/tag_wrapper.rb', line 71 def do_num_bytes self.real_length = content_size super end |
#do_read(io) ⇒ Object
Nested reads/writes.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/furnace-swf/swf/tag_wrapper.rb', line 44 def do_read(io) super orig_offset = io.offset if Tag.exists_for?(type) @content = Tag.instantiate(type, self, parent) @content.do_read io if io.offset - orig_offset != real_length raise "Invalid tag #{@content}" end else @content = io.readbytes(real_length) end end |
#do_write(io) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/furnace-swf/swf/tag_wrapper.rb', line 61 def do_write(io) super if Tag.exists_for?(type) @content.do_write io else io.writebytes @content end end |
#real_length ⇒ Object
28 29 30 |
# File 'lib/furnace-swf/swf/tag_wrapper.rb', line 28 def real_length short_length == 0x3f ? long_length : short_length end |
#real_length=(value) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/furnace-swf/swf/tag_wrapper.rb', line 32 def real_length=(value) if value >= 0x3f self.short_length = 0x3f self.long_length = value else self.short_length = value self.long_length = 0 end end |
#short_length ⇒ Object
20 21 22 |
# File 'lib/furnace-swf/swf/tag_wrapper.rb', line 20 def short_length type_and_length & 0x3f end |
#short_length=(value) ⇒ Object
24 25 26 |
# File 'lib/furnace-swf/swf/tag_wrapper.rb', line 24 def short_length=(value) self.type_and_length = (type_and_length & 0xfffc) | (value & 0x3f) end |
#type ⇒ Object
Accessors for braindead format.
12 13 14 |
# File 'lib/furnace-swf/swf/tag_wrapper.rb', line 12 def type type_and_length >> 6 end |
#type=(value) ⇒ Object
16 17 18 |
# File 'lib/furnace-swf/swf/tag_wrapper.rb', line 16 def type=(value) self.type_and_length = (type_and_length & 0x3f) | (value << 6) end |