Class: SwfRuby::SpriteDumper
- Inherits:
-
Object
- Object
- SwfRuby::SpriteDumper
- Defined in:
- lib/swf_ruby/sprite_dumper.rb
Overview
DefineSpriteをダンプするクラス.
Instance Attribute Summary collapse
-
#frame_count ⇒ Object
readonly
Returns the value of attribute frame_count.
-
#sprite_id ⇒ Object
readonly
Returns the value of attribute sprite_id.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#tags_addresses ⇒ Object
readonly
Returns the value of attribute tags_addresses.
Instance Method Summary collapse
-
#dump(tag) ⇒ Object
ダンプして構造をインスタンス変数に格納.
-
#initialize ⇒ SpriteDumper
constructor
初期化.
Constructor Details
#initialize ⇒ SpriteDumper
初期化.
12 13 14 15 16 17 |
# File 'lib/swf_ruby/sprite_dumper.rb', line 12 def initialize @sprite_id = nil @frame_count = nil @tag = nil @tags_addresses = nil end |
Instance Attribute Details
#frame_count ⇒ Object (readonly)
Returns the value of attribute frame_count.
7 8 9 |
# File 'lib/swf_ruby/sprite_dumper.rb', line 7 def frame_count @frame_count end |
#sprite_id ⇒ Object (readonly)
Returns the value of attribute sprite_id.
6 7 8 |
# File 'lib/swf_ruby/sprite_dumper.rb', line 6 def sprite_id @sprite_id end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
8 9 10 |
# File 'lib/swf_ruby/sprite_dumper.rb', line 8 def @tags end |
#tags_addresses ⇒ Object (readonly)
Returns the value of attribute tags_addresses.
9 10 11 |
# File 'lib/swf_ruby/sprite_dumper.rb', line 9 def @tags_addresses end |
Instance Method Details
#dump(tag) ⇒ Object
ダンプして構造をインスタンス変数に格納.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/swf_ruby/sprite_dumper.rb', line 20 def dump(tag) data = tag.data @sprite_id = data[0, 2].unpack("v").first @frame_count = data[2, 2].unpack("v").first @tags = [] @tags_addresses = [] sprite_header_length = (tag.long_header) ? 6 : 2 tag_index = 4 while tag_index < data.length @tags_addresses << tag_index + sprite_header_length tag = Swf::Tag.new(data[tag_index..-1]) tag_index += tag.length @tags << tag end self end |